diff --git a/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs b/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs index 4e4a6038..eec969be 100644 --- a/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs +++ b/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs @@ -3,7 +3,6 @@ using OpenAI.Files; using System; using System.ClientModel; -using System.Collections.Generic; using System.IO; using System.Threading; diff --git a/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs b/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs index 319e9017..1c26d729 100644 --- a/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs +++ b/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs @@ -3,7 +3,6 @@ using OpenAI.Files; using System; using System.ClientModel; -using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; diff --git a/examples/Assistants/Example03_ListAssistantsWithPagination.cs b/examples/Assistants/Example03_ListAssistantsWithPagination.cs index 339bb8af..d092a7d2 100644 --- a/examples/Assistants/Example03_ListAssistantsWithPagination.cs +++ b/examples/Assistants/Example03_ListAssistantsWithPagination.cs @@ -2,7 +2,6 @@ using OpenAI.Assistants; using System; using System.ClientModel; -using System.Collections.Generic; namespace OpenAI.Examples; diff --git a/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs b/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs index 7ae4808c..cf2d67aa 100644 --- a/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs +++ b/examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs @@ -2,7 +2,6 @@ using OpenAI.Assistants; using System; using System.ClientModel; -using System.Collections.Generic; using System.Threading.Tasks; namespace OpenAI.Examples; diff --git a/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterLogOutput.cs b/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterLogOutput.cs index 4d0a1d8e..de2a72a8 100644 --- a/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterLogOutput.cs +++ b/src/Custom/Assistants/Internal/InternalRunStepCodeInterpreterLogOutput.cs @@ -1,11 +1,10 @@ -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +/// Text output from the Code Interpreter tool call as part of a run step. +[CodeGenModel("RunStepDetailsToolCallsCodeOutputLogsObject")] +internal partial class InternalRunStepCodeInterpreterLogOutput : RunStepCodeInterpreterOutput { - /// Text output from the Code Interpreter tool call as part of a run step. - [CodeGenModel("RunStepDetailsToolCallsCodeOutputLogsObject")] - internal partial class InternalRunStepCodeInterpreterLogOutput : RunStepCodeInterpreterOutput - { - /// The text output from the Code Interpreter tool call. - [CodeGenMember("Logs")] - public string InternalLogs { get; } - } -} + /// The text output from the Code Interpreter tool call. + [CodeGenMember("Logs")] + public string InternalLogs { get; } +} \ No newline at end of file diff --git a/src/Custom/Assistants/MessageCreationOptions.Serialization.cs b/src/Custom/Assistants/MessageCreationOptions.Serialization.cs index abbbc25d..1036133e 100644 --- a/src/Custom/Assistants/MessageCreationOptions.Serialization.cs +++ b/src/Custom/Assistants/MessageCreationOptions.Serialization.cs @@ -1,25 +1,24 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageCreationOptions : IJsonModel { - public partial class MessageCreationOptions : IJsonModel + private void SerializeContent(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) { - private void SerializeContent(Utf8JsonWriter writer, ModelReaderWriterOptions options = null) + if (Content.Count == 1 && Content[0] is InternalRequestMessageTextContent textContent) { - if (Content.Count == 1 && Content[0] is InternalRequestMessageTextContent textContent) - { - writer.WriteStringValue(textContent.Text); - } - else + writer.WriteStringValue(textContent.Text); + } + else + { + writer.WriteStartArray(); + foreach (var item in Content) { - writer.WriteStartArray(); - foreach (var item in Content) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } } -} +} \ No newline at end of file diff --git a/src/Custom/Assistants/RunStepDetails.cs b/src/Custom/Assistants/RunStepDetails.cs index e003f0ec..de526f5c 100644 --- a/src/Custom/Assistants/RunStepDetails.cs +++ b/src/Custom/Assistants/RunStepDetails.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[Experimental("OPENAI001")] +[CodeGenModel("RunStepObjectStepDetails")] +public abstract partial class RunStepDetails { - [Experimental("OPENAI001")] - [CodeGenModel("RunStepObjectStepDetails")] - public abstract partial class RunStepDetails - { - public string CreatedMessageId => AsInternalMessageCreation?.InternalMessageId; - public IReadOnlyList ToolCalls => AsInternalToolCalls ?? []; + public string CreatedMessageId => AsInternalMessageCreation?.InternalMessageId; + public IReadOnlyList ToolCalls => AsInternalToolCalls ?? []; - private InternalRunStepDetailsMessageCreationObject AsInternalMessageCreation => this as InternalRunStepDetailsMessageCreationObject; - private InternalRunStepDetailsToolCallsObject AsInternalToolCalls => this as InternalRunStepDetailsToolCallsObject; - } -} + private InternalRunStepDetailsMessageCreationObject AsInternalMessageCreation => this as InternalRunStepDetailsMessageCreationObject; + private InternalRunStepDetailsToolCallsObject AsInternalToolCalls => this as InternalRunStepDetailsToolCallsObject; +} \ No newline at end of file diff --git a/src/Custom/Assistants/RunTruncationStrategy.cs b/src/Custom/Assistants/RunTruncationStrategy.cs index d4328f34..5eb39126 100644 --- a/src/Custom/Assistants/RunTruncationStrategy.cs +++ b/src/Custom/Assistants/RunTruncationStrategy.cs @@ -2,69 +2,68 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +/// Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. +[Experimental("OPENAI001")] +[CodeGenModel("TruncationObject")] +[CodeGenSuppress(nameof(RunTruncationStrategy), typeof(InternalTruncationObjectType))] +public partial class RunTruncationStrategy { - /// Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. - [Experimental("OPENAI001")] - [CodeGenModel("TruncationObject")] - [CodeGenSuppress(nameof(RunTruncationStrategy), typeof(InternalTruncationObjectType))] - public partial class RunTruncationStrategy - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary SerializedAdditionalRawData; + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary SerializedAdditionalRawData; - /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - [CodeGenMember("Type")] - internal readonly InternalTruncationObjectType _type; + /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + [CodeGenMember("Type")] + internal readonly InternalTruncationObjectType _type; - /// The number of most recent messages from the thread when constructing the context for the run. - /// - /// - [CodeGenMember("LastMessages")] - public int? LastMessages { get; } + /// The number of most recent messages from the thread when constructing the context for the run. + /// + /// + [CodeGenMember("LastMessages")] + public int? LastMessages { get; } - /// - /// The default that will eliminate messages in the middle of the thread - /// to fit within the context length of the model or the max prompt tokens. - /// - public static RunTruncationStrategy Auto { get; } = new(InternalTruncationObjectType.Auto, 0, null); + /// + /// The default that will eliminate messages in the middle of the thread + /// to fit within the context length of the model or the max prompt tokens. + /// + public static RunTruncationStrategy Auto { get; } = new(InternalTruncationObjectType.Auto, 0, null); - /// - /// Creates a new instance using the last_messages strategy type, - /// which will truncate the thread to specified count of preceding messages for the run. - /// - /// The count of last messages that the run should evaluate. - /// - public static RunTruncationStrategy CreateLastMessagesStrategy(int lastMessageCount) - => new(InternalTruncationObjectType.LastMessages, lastMessageCount, null); - } -} + /// + /// Creates a new instance using the last_messages strategy type, + /// which will truncate the thread to specified count of preceding messages for the run. + /// + /// The count of last messages that the run should evaluate. + /// + public static RunTruncationStrategy CreateLastMessagesStrategy(int lastMessageCount) + => new(InternalTruncationObjectType.LastMessages, lastMessageCount, null); +} \ No newline at end of file diff --git a/src/Custom/Audio/AudioTranscriptionOptions.cs b/src/Custom/Audio/AudioTranscriptionOptions.cs index b13679e0..971bbac5 100644 --- a/src/Custom/Audio/AudioTranscriptionOptions.cs +++ b/src/Custom/Audio/AudioTranscriptionOptions.cs @@ -1,4 +1,3 @@ -using OpenAI.Internal; using System; using System.Collections.Generic; using System.IO; diff --git a/src/Custom/Audio/AudioTranslationOptions.cs b/src/Custom/Audio/AudioTranslationOptions.cs index 7632ed9c..395183ab 100644 --- a/src/Custom/Audio/AudioTranslationOptions.cs +++ b/src/Custom/Audio/AudioTranslationOptions.cs @@ -1,6 +1,3 @@ -using OpenAI.Embeddings; -using OpenAI.Images; -using OpenAI.Internal; using System; using System.IO; diff --git a/src/Custom/Chat/ChatResponseFormat.Serialization.cs b/src/Custom/Chat/ChatResponseFormat.Serialization.cs index ff7fdeaa..4df2335e 100644 --- a/src/Custom/Chat/ChatResponseFormat.Serialization.cs +++ b/src/Custom/Chat/ChatResponseFormat.Serialization.cs @@ -1,7 +1,4 @@ -using System; using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Runtime.CompilerServices; using System.Text.Json; namespace OpenAI.Chat; diff --git a/src/Custom/Chat/ChatTokenTopLogProbabilityDetails.cs b/src/Custom/Chat/ChatTokenTopLogProbabilityDetails.cs index 3260ce64..df737dee 100644 --- a/src/Custom/Chat/ChatTokenTopLogProbabilityDetails.cs +++ b/src/Custom/Chat/ChatTokenTopLogProbabilityDetails.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace OpenAI.Chat; diff --git a/src/Custom/Chat/ChatToolCall.cs b/src/Custom/Chat/ChatToolCall.cs index 65f57ede..a35acb40 100644 --- a/src/Custom/Chat/ChatToolCall.cs +++ b/src/Custom/Chat/ChatToolCall.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace OpenAI.Chat; diff --git a/src/Custom/Chat/Internal/InternalChatResponseFormatJsonSchema.cs b/src/Custom/Chat/Internal/InternalChatResponseFormatJsonSchema.cs index cd9e63b5..9107b051 100644 --- a/src/Custom/Chat/Internal/InternalChatResponseFormatJsonSchema.cs +++ b/src/Custom/Chat/Internal/InternalChatResponseFormatJsonSchema.cs @@ -1,9 +1,4 @@ -using System.ClientModel.Primitives; -using System.Data; -using System.Text.Json; -using System; - -namespace OpenAI.Chat; +namespace OpenAI.Chat; [CodeGenModel("ChatResponseFormatJsonSchema")] internal partial class InternalChatResponseFormatJsonSchema diff --git a/src/Custom/Chat/Streaming/StreamingChatToolCallUpdate.cs b/src/Custom/Chat/Streaming/StreamingChatToolCallUpdate.cs index c53055a2..19f37212 100644 --- a/src/Custom/Chat/Streaming/StreamingChatToolCallUpdate.cs +++ b/src/Custom/Chat/Streaming/StreamingChatToolCallUpdate.cs @@ -1,8 +1,4 @@ namespace OpenAI.Chat; - -using System; -using System.Text.Json; - /// /// A base representation of an incremental update to a streaming tool call that is part of a streaming chat completion /// request. diff --git a/src/Custom/FineTuning/FineTuningClient.Protocol.cs b/src/Custom/FineTuning/FineTuningClient.Protocol.cs index 513a00f7..1e9a74c8 100644 --- a/src/Custom/FineTuning/FineTuningClient.Protocol.cs +++ b/src/Custom/FineTuning/FineTuningClient.Protocol.cs @@ -1,7 +1,6 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Threading.Tasks; namespace OpenAI.FineTuning; diff --git a/src/Custom/Models/OpenAIModelInfoCollection.Serialization.cs b/src/Custom/Models/OpenAIModelInfoCollection.Serialization.cs index 6cfc9383..bfaaed2d 100644 --- a/src/Custom/Models/OpenAIModelInfoCollection.Serialization.cs +++ b/src/Custom/Models/OpenAIModelInfoCollection.Serialization.cs @@ -1,9 +1,6 @@ -using OpenAI.Models; using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Reflection; using System.Text.Json; namespace OpenAI.Models; diff --git a/src/Custom/Models/OpenAIModelInfoCollection.cs b/src/Custom/Models/OpenAIModelInfoCollection.cs index 773bab8f..e35580a4 100644 --- a/src/Custom/Models/OpenAIModelInfoCollection.cs +++ b/src/Custom/Models/OpenAIModelInfoCollection.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Reflection; namespace OpenAI.Models; diff --git a/src/Custom/VectorStores/VectorStoreCreationOptions.cs b/src/Custom/VectorStores/VectorStoreCreationOptions.cs index a421d590..b90caf0e 100644 --- a/src/Custom/VectorStores/VectorStoreCreationOptions.cs +++ b/src/Custom/VectorStores/VectorStoreCreationOptions.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; namespace OpenAI.VectorStores; diff --git a/src/Generated/AssistantClient.cs b/src/Generated/AssistantClient.cs index 14c304e8..40ab06b9 100644 --- a/src/Generated/AssistantClient.cs +++ b/src/Generated/AssistantClient.cs @@ -5,124 +5,122 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +// Data plane generated sub-client. +public partial class AssistantClient { - // Data plane generated sub-client. - public partial class AssistantClient + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected AssistantClient() { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + } - public virtual ClientPipeline Pipeline => _pipeline; + internal PipelineMessage CreateCreateAssistantRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - protected AssistantClient() + internal PipelineMessage CreateGetAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants", false); + if (limit != null) { + uri.AppendQuery("limit", limit.Value, true); } - - internal PipelineMessage CreateCreateAssistantRequest(BinaryContent content, RequestOptions options) + if (order != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/assistants", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("order", order, true); } - - internal PipelineMessage CreateGetAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/assistants", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateGetAssistantRequest(string assistantId, RequestOptions options) + if (before != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/assistants/", false); - uri.AppendPath(assistantId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("before", before, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateModifyAssistantRequest(string assistantId, BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/assistants/", false); - uri.AppendPath(assistantId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateGetAssistantRequest(string assistantId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants/", false); + uri.AppendPath(assistantId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateDeleteAssistantRequest(string assistantId, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/assistants/", false); - uri.AppendPath(assistantId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateModifyAssistantRequest(string assistantId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants/", false); + uri.AppendPath(assistantId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateDeleteAssistantRequest(string assistantId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "DELETE"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/assistants/", false); + uri.AppendPath(assistantId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/AudioClient.cs b/src/Generated/AudioClient.cs index 8b5a4f1d..af43fa68 100644 --- a/src/Generated/AudioClient.cs +++ b/src/Generated/AudioClient.cs @@ -5,77 +5,75 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Audio -{ - // Data plane generated sub-client. - public partial class AudioClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; +namespace OpenAI.Audio; - public virtual ClientPipeline Pipeline => _pipeline; +// Data plane generated sub-client. +public partial class AudioClient +{ + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - protected AudioClient() - { - } + public virtual ClientPipeline Pipeline => _pipeline; - internal PipelineMessage CreateCreateSpeechRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/audio/speech", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/octet-stream"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + protected AudioClient() + { + } - internal PipelineMessage CreateCreateTranscriptionRequest(BinaryContent content, string contentType, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/audio/transcriptions", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", contentType); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateSpeechRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/audio/speech", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/octet-stream"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateCreateTranslationRequest(BinaryContent content, string contentType, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/audio/translations", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", contentType); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateTranscriptionRequest(BinaryContent content, string contentType, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/audio/transcriptions", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", contentType); + request.Content = content; + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateCreateTranslationRequest(BinaryContent content, string contentType, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/audio/translations", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", contentType); + request.Content = content; + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/BatchClient.cs b/src/Generated/BatchClient.cs index 3ccd2f90..338e7485 100644 --- a/src/Generated/BatchClient.cs +++ b/src/Generated/BatchClient.cs @@ -5,100 +5,97 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Threading.Tasks; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +// Data plane generated sub-client. +public partial class BatchClient { - // Data plane generated sub-client. - public partial class BatchClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - public virtual ClientPipeline Pipeline => _pipeline; + public virtual ClientPipeline Pipeline => _pipeline; - protected BatchClient() - { - } + protected BatchClient() + { + } - internal PipelineMessage CreateCreateBatchRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/batches", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateBatchRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/batches", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateGetBatchesRequest(string after, int? limit, RequestOptions options) + internal PipelineMessage CreateGetBatchesRequest(string after, int? limit, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/batches", false); + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/batches", false); - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateRetrieveBatchRequest(string batchId, RequestOptions options) + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/batches/", false); - uri.AppendPath(batchId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateCancelBatchRequest(string batchId, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateRetrieveBatchRequest(string batchId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/batches/", false); + uri.AppendPath(batchId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateCancelBatchRequest(string batchId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/cancel", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/ChatClient.cs b/src/Generated/ChatClient.cs index 6db94d5e..a15d1d52 100644 --- a/src/Generated/ChatClient.cs +++ b/src/Generated/ChatClient.cs @@ -5,43 +5,41 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +// Data plane generated sub-client. +public partial class ChatClient { - // Data plane generated sub-client. - public partial class ChatClient + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected ChatClient() { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - - public virtual ClientPipeline Pipeline => _pipeline; - - protected ChatClient() - { - } - - internal PipelineMessage CreateCreateChatCompletionRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/chat/completions", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); } -} + + internal PipelineMessage CreateCreateChatCompletionRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/chat/completions", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/EmbeddingClient.cs b/src/Generated/EmbeddingClient.cs index e93cade4..bd71146c 100644 --- a/src/Generated/EmbeddingClient.cs +++ b/src/Generated/EmbeddingClient.cs @@ -5,43 +5,41 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +// Data plane generated sub-client. +public partial class EmbeddingClient { - // Data plane generated sub-client. - public partial class EmbeddingClient + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected EmbeddingClient() { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - - public virtual ClientPipeline Pipeline => _pipeline; - - protected EmbeddingClient() - { - } - - internal PipelineMessage CreateCreateEmbeddingRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/embeddings", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); } -} + + internal PipelineMessage CreateCreateEmbeddingRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/embeddings", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/FileClient.cs b/src/Generated/FileClient.cs index 131f6ba5..a38869dd 100644 --- a/src/Generated/FileClient.cs +++ b/src/Generated/FileClient.cs @@ -5,111 +5,109 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Files +namespace OpenAI.Files; + +// Data plane generated sub-client. +public partial class FileClient { - // Data plane generated sub-client. - public partial class FileClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - public virtual ClientPipeline Pipeline => _pipeline; + public virtual ClientPipeline Pipeline => _pipeline; - protected FileClient() - { - } - - internal PipelineMessage CreateCreateFileRequest(BinaryContent content, string contentType, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/files", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", contentType); - request.Content = content; - message.Apply(options); - return message; - } + protected FileClient() + { + } - internal PipelineMessage CreateGetFilesRequest(string purpose, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/files", false); - if (purpose != null) - { - uri.AppendQuery("purpose", purpose, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateFileRequest(BinaryContent content, string contentType, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", contentType); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateRetrieveFileRequest(string fileId, RequestOptions options) + internal PipelineMessage CreateGetFilesRequest(string purpose, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files", false); + if (purpose != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("purpose", purpose, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateDeleteFileRequest(string fileId, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateRetrieveFileRequest(string fileId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateDownloadFileRequest(string fileId, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - uri.AppendPath("/content", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateDeleteFileRequest(string fileId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "DELETE"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateDownloadFileRequest(string fileId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + uri.AppendPath("/content", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/FineTuningClient.cs b/src/Generated/FineTuningClient.cs index c4446699..c1b0f5ab 100644 --- a/src/Generated/FineTuningClient.cs +++ b/src/Generated/FineTuningClient.cs @@ -5,149 +5,147 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +// Data plane generated sub-client. +public partial class FineTuningClient { - // Data plane generated sub-client. - public partial class FineTuningClient + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected FineTuningClient() { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + } - public virtual ClientPipeline Pipeline => _pipeline; + internal PipelineMessage CreateCreateFineTuningJobRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/fine_tuning/jobs", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - protected FineTuningClient() + internal PipelineMessage CreateGetPaginatedFineTuningJobsRequest(string after, int? limit, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/fine_tuning/jobs", false); + if (after != null) { + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateCreateFineTuningJobRequest(BinaryContent content, RequestOptions options) + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/fine_tuning/jobs", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateGetPaginatedFineTuningJobsRequest(string after, int? limit, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/fine_tuning/jobs", false); - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateRetrieveFineTuningJobRequest(string fineTuningJobId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/fine_tuning/jobs/", false); + uri.AppendPath(fineTuningJobId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCancelFineTuningJobRequest(string fineTuningJobId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/fine_tuning/jobs/", false); + uri.AppendPath(fineTuningJobId, true); + uri.AppendPath("/cancel", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateRetrieveFineTuningJobRequest(string fineTuningJobId, RequestOptions options) + internal PipelineMessage CreateGetFineTuningJobCheckpointsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/fine_tuning/jobs/", false); + uri.AppendPath(fineTuningJobId, true); + uri.AppendPath("/checkpoints", false); + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/fine_tuning/jobs/", false); - uri.AppendPath(fineTuningJobId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateCancelFineTuningJobRequest(string fineTuningJobId, RequestOptions options) + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/fine_tuning/jobs/", false); - uri.AppendPath(fineTuningJobId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateGetFineTuningJobCheckpointsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) + internal PipelineMessage CreateGetFineTuningEventsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/fine_tuning/jobs/", false); + uri.AppendPath(fineTuningJobId, true); + uri.AppendPath("/events", false); + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/fine_tuning/jobs/", false); - uri.AppendPath(fineTuningJobId, true); - uri.AppendPath("/checkpoints", false); - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateGetFineTuningEventsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/fine_tuning/jobs/", false); - uri.AppendPath(fineTuningJobId, true); - uri.AppendPath("/events", false); - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/ImageClient.cs b/src/Generated/ImageClient.cs index 6e0558f0..1d5d314f 100644 --- a/src/Generated/ImageClient.cs +++ b/src/Generated/ImageClient.cs @@ -5,77 +5,75 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Images -{ - // Data plane generated sub-client. - public partial class ImageClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; +namespace OpenAI.Images; - public virtual ClientPipeline Pipeline => _pipeline; +// Data plane generated sub-client. +public partial class ImageClient +{ + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - protected ImageClient() - { - } + public virtual ClientPipeline Pipeline => _pipeline; - internal PipelineMessage CreateCreateImageRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/images/generations", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + protected ImageClient() + { + } - internal PipelineMessage CreateCreateImageEditRequest(BinaryContent content, string contentType, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/images/edits", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", contentType); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateImageRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/images/generations", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateCreateImageVariationRequest(BinaryContent content, string contentType, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/images/variations", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", contentType); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateImageEditRequest(BinaryContent content, string contentType, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/images/edits", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", contentType); + request.Content = content; + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateCreateImageVariationRequest(BinaryContent content, string contentType, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/images/variations", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", contentType); + request.Content = content; + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/Internal/Argument.cs b/src/Generated/Internal/Argument.cs index 29cb5ac1..cb34ba36 100644 --- a/src/Generated/Internal/Argument.cs +++ b/src/Generated/Internal/Argument.cs @@ -6,121 +6,120 @@ using System.Collections; using System.Collections.Generic; -namespace OpenAI +namespace OpenAI; + +internal static class Argument { - internal static class Argument + public static void AssertNotNull(T value, string name) { - public static void AssertNotNull(T value, string name) + if (value is null) { - if (value is null) - { - throw new ArgumentNullException(name); - } + throw new ArgumentNullException(name); } + } - public static void AssertNotNull(T? value, string name) - where T : struct + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) { - if (!value.HasValue) - { - throw new ArgumentNullException(name); - } + throw new ArgumentNullException(name); } + } - public static void AssertNotNullOrEmpty(IEnumerable value, string name) + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (value is ICollection collectionOfT && collectionOfT.Count == 0) - { - throw new ArgumentException("Value cannot be an empty collection.", name); - } - if (value is ICollection collection && collection.Count == 0) - { - throw new ArgumentException("Value cannot be an empty collection.", name); - } - using IEnumerator e = value.GetEnumerator(); - if (!e.MoveNext()) - { - throw new ArgumentException("Value cannot be an empty collection.", name); - } + throw new ArgumentNullException(name); } - - public static void AssertNotNullOrEmpty(string value, string name) + if (value is ICollection collectionOfT && collectionOfT.Count == 0) { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (value.Length == 0) - { - throw new ArgumentException("Value cannot be an empty string.", name); - } + throw new ArgumentException("Value cannot be an empty collection.", name); } - - public static void AssertNotNullOrWhiteSpace(string value, string name) + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); - } + throw new ArgumentException("Value cannot be an empty collection.", name); } + } - public static void AssertNotDefault(ref T value, string name) - where T : struct, IEquatable + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) { - if (value.Equals(default)) - { - throw new ArgumentException("Value cannot be empty.", name); - } + throw new ArgumentException("Value cannot be an empty string.", name); } + } - public static void AssertInRange(T value, T minimum, T maximum, string name) - where T : notnull, IComparable + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) { - if (minimum.CompareTo(value) > 0) - { - throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); - } - if (maximum.CompareTo(value) < 0) - { - throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); - } + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); } + } - public static void AssertEnumDefined(Type enumType, object value, string name) + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) { - if (!Enum.IsDefined(enumType, value)) - { - throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); - } + throw new ArgumentException("Value cannot be empty.", name); } + } - public static T CheckNotNull(T value, string name) - where T : class + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) { - AssertNotNull(value, name); - return value; + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } - public static string CheckNotNullOrEmpty(string value, string name) + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) { - AssertNotNullOrEmpty(value, name); - return value; + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } - public static void AssertNull(T value, string name, string message = null) + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) { - if (value != null) - { - throw new ArgumentException(message ?? "Value must be null.", name); - } + throw new ArgumentException(message ?? "Value must be null.", name); } } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/BinaryContentHelper.cs b/src/Generated/Internal/BinaryContentHelper.cs index 52bcdbdf..c90621af 100644 --- a/src/Generated/Internal/BinaryContentHelper.cs +++ b/src/Generated/Internal/BinaryContentHelper.cs @@ -7,127 +7,126 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI +namespace OpenAI; + +internal static class BinaryContentHelper { - internal static class BinaryContentHelper + public static BinaryContent FromEnumerable(IEnumerable enumerable) + where T : notnull { - public static BinaryContent FromEnumerable(IEnumerable enumerable) - where T : notnull + Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); + content.JsonWriter.WriteStartArray(); + foreach (var item in enumerable) { - Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); - content.JsonWriter.WriteStartArray(); - foreach (var item in enumerable) - { - content.JsonWriter.WriteObjectValue(item, ModelSerializationExtensions.WireOptions); - } - content.JsonWriter.WriteEndArray(); - - return content; + content.JsonWriter.WriteObjectValue(item, ModelSerializationExtensions.WireOptions); } + content.JsonWriter.WriteEndArray(); - public static BinaryContent FromEnumerable(IEnumerable enumerable) + return content; + } + + public static BinaryContent FromEnumerable(IEnumerable enumerable) + { + Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); + content.JsonWriter.WriteStartArray(); + foreach (var item in enumerable) { - Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); - content.JsonWriter.WriteStartArray(); - foreach (var item in enumerable) + if (item == null) + { + content.JsonWriter.WriteNullValue(); + } + else { - if (item == null) - { - content.JsonWriter.WriteNullValue(); - } - else - { #if NET6_0_OR_GREATER content.JsonWriter.WriteRawValue(item); #else - using (JsonDocument document = JsonDocument.Parse(item)) - { - JsonSerializer.Serialize(content.JsonWriter, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); } +#endif } - content.JsonWriter.WriteEndArray(); - - return content; } + content.JsonWriter.WriteEndArray(); - public static BinaryContent FromEnumerable(ReadOnlySpan span) - where T : notnull - { - Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); - content.JsonWriter.WriteStartArray(); - for (int i = 0; i < span.Length; i++) - { - content.JsonWriter.WriteObjectValue(span[i], ModelSerializationExtensions.WireOptions); - } - content.JsonWriter.WriteEndArray(); + return content; + } - return content; + public static BinaryContent FromEnumerable(ReadOnlySpan span) + where T : notnull + { + Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); + content.JsonWriter.WriteStartArray(); + for (int i = 0; i < span.Length; i++) + { + content.JsonWriter.WriteObjectValue(span[i], ModelSerializationExtensions.WireOptions); } + content.JsonWriter.WriteEndArray(); - public static BinaryContent FromDictionary(IDictionary dictionary) - where TValue : notnull - { - Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); - content.JsonWriter.WriteStartObject(); - foreach (var item in dictionary) - { - content.JsonWriter.WritePropertyName(item.Key); - content.JsonWriter.WriteObjectValue(item.Value, ModelSerializationExtensions.WireOptions); - } - content.JsonWriter.WriteEndObject(); + return content; + } - return content; + public static BinaryContent FromDictionary(IDictionary dictionary) + where TValue : notnull + { + Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); + content.JsonWriter.WriteStartObject(); + foreach (var item in dictionary) + { + content.JsonWriter.WritePropertyName(item.Key); + content.JsonWriter.WriteObjectValue(item.Value, ModelSerializationExtensions.WireOptions); } + content.JsonWriter.WriteEndObject(); + + return content; + } - public static BinaryContent FromDictionary(IDictionary dictionary) + public static BinaryContent FromDictionary(IDictionary dictionary) + { + Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); + content.JsonWriter.WriteStartObject(); + foreach (var item in dictionary) { - Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); - content.JsonWriter.WriteStartObject(); - foreach (var item in dictionary) + content.JsonWriter.WritePropertyName(item.Key); + if (item.Value == null) + { + content.JsonWriter.WriteNullValue(); + } + else { - content.JsonWriter.WritePropertyName(item.Key); - if (item.Value == null) - { - content.JsonWriter.WriteNullValue(); - } - else - { #if NET6_0_OR_GREATER content.JsonWriter.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(content.JsonWriter, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); } +#endif } - content.JsonWriter.WriteEndObject(); - - return content; } + content.JsonWriter.WriteEndObject(); - public static BinaryContent FromObject(object value) - { - Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); - content.JsonWriter.WriteObjectValue(value, ModelSerializationExtensions.WireOptions); - return content; - } + return content; + } - public static BinaryContent FromObject(BinaryData value) - { - Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); + public static BinaryContent FromObject(object value) + { + Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); + content.JsonWriter.WriteObjectValue(value, ModelSerializationExtensions.WireOptions); + return content; + } + + public static BinaryContent FromObject(BinaryData value) + { + Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); #if NET6_0_OR_GREATER content.JsonWriter.WriteRawValue(value); #else - using (JsonDocument document = JsonDocument.Parse(value)) - { - JsonSerializer.Serialize(content.JsonWriter, document.RootElement); - } -#endif - return content; + using (JsonDocument document = JsonDocument.Parse(value)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); } +#endif + return content; } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/ChangeTrackingDictionary.cs b/src/Generated/Internal/ChangeTrackingDictionary.cs index 2eb05d04..cd406322 100644 --- a/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -6,159 +6,158 @@ using System.Collections; using System.Collections.Generic; -namespace OpenAI +namespace OpenAI; + +internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() { - private IDictionary _innerDictionary; + } - public ChangeTrackingDictionary() + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) { + return; } + _innerDictionary = new Dictionary(dictionary); + } - public ChangeTrackingDictionary(IDictionary dictionary) + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) { - if (dictionary == null) - { - return; - } - _innerDictionary = new Dictionary(dictionary); + return; } - - public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) { - if (dictionary == null) - { - return; - } - _innerDictionary = new Dictionary(); - foreach (var pair in dictionary) - { - _innerDictionary.Add(pair); - } + _innerDictionary.Add(pair); } + } - public bool IsUndefined => _innerDictionary == null; + public bool IsUndefined => _innerDictionary == null; - public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; - public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; - public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; - public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; - public TValue this[TKey key] + public TValue this[TKey key] + { + get { - get - { - if (IsUndefined) - { - throw new KeyNotFoundException(nameof(key)); - } - return EnsureDictionary()[key]; - } - set + if (IsUndefined) { - EnsureDictionary()[key] = value; + throw new KeyNotFoundException(nameof(key)); } + return EnsureDictionary()[key]; } + set + { + EnsureDictionary()[key] = value; + } + } - IEnumerable IReadOnlyDictionary.Keys => Keys; + IEnumerable IReadOnlyDictionary.Keys => Keys; - IEnumerable IReadOnlyDictionary.Values => Values; + IEnumerable IReadOnlyDictionary.Values => Values; - public IEnumerator> GetEnumerator() + public IEnumerator> GetEnumerator() + { + if (IsUndefined) { - if (IsUndefined) + IEnumerator> enumerateEmpty() { - IEnumerator> enumerateEmpty() - { - yield break; - } - return enumerateEmpty(); + yield break; } - return EnsureDictionary().GetEnumerator(); + return enumerateEmpty(); } + return EnsureDictionary().GetEnumerator(); + } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } - public void Add(KeyValuePair item) - { - EnsureDictionary().Add(item); - } + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } - public void Clear() - { - EnsureDictionary().Clear(); - } + public void Clear() + { + EnsureDictionary().Clear(); + } - public bool Contains(KeyValuePair item) + public bool Contains(KeyValuePair item) + { + if (IsUndefined) { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().Contains(item); + return false; } + return EnsureDictionary().Contains(item); + } - public void CopyTo(KeyValuePair[] array, int index) + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) { - if (IsUndefined) - { - return; - } - EnsureDictionary().CopyTo(array, index); + return; } + EnsureDictionary().CopyTo(array, index); + } - public bool Remove(KeyValuePair item) + public bool Remove(KeyValuePair item) + { + if (IsUndefined) { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().Remove(item); + return false; } + return EnsureDictionary().Remove(item); + } - public void Add(TKey key, TValue value) - { - EnsureDictionary().Add(key, value); - } + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } - public bool ContainsKey(TKey key) + public bool ContainsKey(TKey key) + { + if (IsUndefined) { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().ContainsKey(key); + return false; } + return EnsureDictionary().ContainsKey(key); + } - public bool Remove(TKey key) + public bool Remove(TKey key) + { + if (IsUndefined) { - if (IsUndefined) - { - return false; - } - return EnsureDictionary().Remove(key); + return false; } + return EnsureDictionary().Remove(key); + } - public bool TryGetValue(TKey key, out TValue value) + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) { - if (IsUndefined) - { - value = default; - return false; - } - return EnsureDictionary().TryGetValue(key, out value); + value = default; + return false; } + return EnsureDictionary().TryGetValue(key, out value); + } - public IDictionary EnsureDictionary() - { - return _innerDictionary ??= new Dictionary(); - } + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/ChangeTrackingList.cs b/src/Generated/Internal/ChangeTrackingList.cs index c64afc50..a4d7bf66 100644 --- a/src/Generated/Internal/ChangeTrackingList.cs +++ b/src/Generated/Internal/ChangeTrackingList.cs @@ -7,144 +7,143 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI +namespace OpenAI; + +internal class ChangeTrackingList : IList, IReadOnlyList { - internal class ChangeTrackingList : IList, IReadOnlyList - { - private IList _innerList; + private IList _innerList; - public ChangeTrackingList() - { - } + public ChangeTrackingList() + { + } - public ChangeTrackingList(IList innerList) + public ChangeTrackingList(IList innerList) + { + if (innerList != null) { - if (innerList != null) - { - _innerList = innerList; - } + _innerList = innerList; } + } - public ChangeTrackingList(IReadOnlyList innerList) + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) { - if (innerList != null) - { - _innerList = innerList.ToList(); - } + _innerList = innerList.ToList(); } + } - public bool IsUndefined => _innerList == null; + public bool IsUndefined => _innerList == null; - public int Count => IsUndefined ? 0 : EnsureList().Count; + public int Count => IsUndefined ? 0 : EnsureList().Count; - public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; - public T this[int index] + public T this[int index] + { + get { - get + if (IsUndefined) { - if (IsUndefined) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - return EnsureList()[index]; + throw new ArgumentOutOfRangeException(nameof(index)); } - set + return EnsureList()[index]; + } + set + { + if (IsUndefined) { - if (IsUndefined) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - EnsureList()[index] = value; + throw new ArgumentOutOfRangeException(nameof(index)); } + EnsureList()[index] = value; } + } - public void Reset() - { - _innerList = null; - } + public void Reset() + { + _innerList = null; + } - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator() + { + if (IsUndefined) { - if (IsUndefined) + IEnumerator enumerateEmpty() { - IEnumerator enumerateEmpty() - { - yield break; - } - return enumerateEmpty(); + yield break; } - return EnsureList().GetEnumerator(); + return enumerateEmpty(); } + return EnsureList().GetEnumerator(); + } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } - public void Add(T item) - { - EnsureList().Add(item); - } + public void Add(T item) + { + EnsureList().Add(item); + } - public void Clear() - { - EnsureList().Clear(); - } + public void Clear() + { + EnsureList().Clear(); + } - public bool Contains(T item) + public bool Contains(T item) + { + if (IsUndefined) { - if (IsUndefined) - { - return false; - } - return EnsureList().Contains(item); + return false; } + return EnsureList().Contains(item); + } - public void CopyTo(T[] array, int arrayIndex) + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) { - if (IsUndefined) - { - return; - } - EnsureList().CopyTo(array, arrayIndex); + return; } + EnsureList().CopyTo(array, arrayIndex); + } - public bool Remove(T item) + public bool Remove(T item) + { + if (IsUndefined) { - if (IsUndefined) - { - return false; - } - return EnsureList().Remove(item); + return false; } + return EnsureList().Remove(item); + } - public int IndexOf(T item) + public int IndexOf(T item) + { + if (IsUndefined) { - if (IsUndefined) - { - return -1; - } - return EnsureList().IndexOf(item); + return -1; } + return EnsureList().IndexOf(item); + } - public void Insert(int index, T item) - { - EnsureList().Insert(index, item); - } + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } - public void RemoveAt(int index) + public void RemoveAt(int index) + { + if (IsUndefined) { - if (IsUndefined) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - EnsureList().RemoveAt(index); + throw new ArgumentOutOfRangeException(nameof(index)); } + EnsureList().RemoveAt(index); + } - public IList EnsureList() - { - return _innerList ??= new List(); - } + public IList EnsureList() + { + return _innerList ??= new List(); } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/ClientPipelineExtensions.cs b/src/Generated/Internal/ClientPipelineExtensions.cs index c51dd675..c1116ded 100644 --- a/src/Generated/Internal/ClientPipelineExtensions.cs +++ b/src/Generated/Internal/ClientPipelineExtensions.cs @@ -6,36 +6,35 @@ using System.ClientModel.Primitives; using System.Threading.Tasks; -namespace OpenAI +namespace OpenAI; + +internal static partial class ClientPipelineExtensions { - internal static partial class ClientPipelineExtensions + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) { - public static async ValueTask> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); + switch (response.Status) { - PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - switch (response.Status) - { - case >= 200 and < 300: - return ClientResult.FromValue(true, response); - case >= 400 and < 500: - return ClientResult.FromValue(false, response); - default: - return new ErrorResult(response, new ClientResultException(response)); - } + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); } + } - public static ClientResult ProcessHeadAsBoolMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + public static ClientResult ProcessHeadAsBoolMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + PipelineResponse response = pipeline.ProcessMessage(message, options); + switch (response.Status) { - PipelineResponse response = pipeline.ProcessMessage(message, options); - switch (response.Status) - { - case >= 200 and < 300: - return ClientResult.FromValue(true, response); - case >= 400 and < 500: - return ClientResult.FromValue(false, response); - default: - return new ErrorResult(response, new ClientResultException(response)); - } + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); } } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/ClientUriBuilder.cs b/src/Generated/Internal/ClientUriBuilder.cs index 9406854d..59aa3f96 100644 --- a/src/Generated/Internal/ClientUriBuilder.cs +++ b/src/Generated/Internal/ClientUriBuilder.cs @@ -7,199 +7,198 @@ using System.Linq; using System.Text; -namespace OpenAI +namespace OpenAI; + +internal class ClientUriBuilder { - internal class ClientUriBuilder + private UriBuilder _uriBuilder; + private StringBuilder _pathBuilder; + private StringBuilder _queryBuilder; + + public ClientUriBuilder() { - private UriBuilder _uriBuilder; - private StringBuilder _pathBuilder; - private StringBuilder _queryBuilder; + } - public ClientUriBuilder() - { - } + private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); + + private StringBuilder PathBuilder => _pathBuilder ??= new StringBuilder(UriBuilder.Path); - private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); + private StringBuilder QueryBuilder => _queryBuilder ??= new StringBuilder(UriBuilder.Query); - private StringBuilder PathBuilder => _pathBuilder ??= new StringBuilder(UriBuilder.Path); + public void Reset(Uri uri) + { + _uriBuilder = new UriBuilder(uri); + _pathBuilder = new StringBuilder(UriBuilder.Path); + _queryBuilder = new StringBuilder(UriBuilder.Query); + } - private StringBuilder QueryBuilder => _queryBuilder ??= new StringBuilder(UriBuilder.Query); + public void AppendPath(string value, bool escape) + { + Argument.AssertNotNullOrWhiteSpace(value, nameof(value)); - public void Reset(Uri uri) + if (escape) { - _uriBuilder = new UriBuilder(uri); - _pathBuilder = new StringBuilder(UriBuilder.Path); - _queryBuilder = new StringBuilder(UriBuilder.Query); + value = Uri.EscapeDataString(value); } - public void AppendPath(string value, bool escape) + if (PathBuilder.Length > 0 && PathBuilder[PathBuilder.Length - 1] == '/' && value[0] == '/') { - Argument.AssertNotNullOrWhiteSpace(value, nameof(value)); + PathBuilder.Remove(PathBuilder.Length - 1, 1); + } - if (escape) - { - value = Uri.EscapeDataString(value); - } + PathBuilder.Append(value); + UriBuilder.Path = PathBuilder.ToString(); + } - if (PathBuilder.Length > 0 && PathBuilder[PathBuilder.Length - 1] == '/' && value[0] == '/') - { - PathBuilder.Remove(PathBuilder.Length - 1, 1); - } + public void AppendPath(bool value, bool escape = false) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - PathBuilder.Append(value); - UriBuilder.Path = PathBuilder.ToString(); - } + public void AppendPath(float value, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendPath(bool value, bool escape = false) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(double value, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendPath(float value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(int value, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendPath(double value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(byte[] value, string format, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); + } - public void AppendPath(int value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(IEnumerable value, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendPath(byte[] value, string format, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendPath(DateTimeOffset value, string format, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); + } - public void AppendPath(IEnumerable value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(TimeSpan value, string format, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); + } - public void AppendPath(DateTimeOffset value, string format, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendPath(Guid value, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendPath(TimeSpan value, string format, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendPath(long value, bool escape = true) + { + AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendPath(Guid value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, string value, bool escape) + { + Argument.AssertNotNullOrWhiteSpace(name, nameof(name)); + Argument.AssertNotNullOrWhiteSpace(value, nameof(value)); - public void AppendPath(long value, bool escape = true) + if (QueryBuilder.Length > 0) { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + QueryBuilder.Append('&'); } - public void AppendQuery(string name, string value, bool escape) + if (escape) { - Argument.AssertNotNullOrWhiteSpace(name, nameof(name)); - Argument.AssertNotNullOrWhiteSpace(value, nameof(value)); - - if (QueryBuilder.Length > 0) - { - QueryBuilder.Append('&'); - } - - if (escape) - { - value = Uri.EscapeDataString(value); - } - - QueryBuilder.Append(name); - QueryBuilder.Append('='); - QueryBuilder.Append(value); + value = Uri.EscapeDataString(value); } - public void AppendQuery(string name, bool value, bool escape = false) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + QueryBuilder.Append(name); + QueryBuilder.Append('='); + QueryBuilder.Append(value); + } - public void AppendQuery(string name, float value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, bool value, bool escape = false) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQuery(string name, DateTimeOffset value, string format, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendQuery(string name, float value, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQuery(string name, TimeSpan value, string format, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendQuery(string name, DateTimeOffset value, string format, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); + } - public void AppendQuery(string name, double value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, TimeSpan value, string format, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); + } - public void AppendQuery(string name, decimal value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, double value, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQuery(string name, int value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, decimal value, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQuery(string name, long value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, int value, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQuery(string name, TimeSpan value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, long value, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQuery(string name, byte[] value, string format, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendQuery(string name, TimeSpan value, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQuery(string name, Guid value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, byte[] value, string format, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); + } - public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, bool escape = true) - { - var stringValues = value.Select(v => ModelSerializationExtensions.TypeFormatters.ConvertToString(v)); - AppendQuery(name, string.Join(delimiter, stringValues), escape); - } + public void AppendQuery(string name, Guid value, bool escape = true) + { + AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + } - public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, string format, bool escape = true) + public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, bool escape = true) + { + var stringValues = value.Select(v => ModelSerializationExtensions.TypeFormatters.ConvertToString(v)); + AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, string format, bool escape = true) + { + var stringValues = value.Select(v => ModelSerializationExtensions.TypeFormatters.ConvertToString(v, format)); + AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public Uri ToUri() + { + if (_pathBuilder != null) { - var stringValues = value.Select(v => ModelSerializationExtensions.TypeFormatters.ConvertToString(v, format)); - AppendQuery(name, string.Join(delimiter, stringValues), escape); + UriBuilder.Path = _pathBuilder.ToString(); } - public Uri ToUri() + if (_queryBuilder != null) { - if (_pathBuilder != null) - { - UriBuilder.Path = _pathBuilder.ToString(); - } - - if (_queryBuilder != null) - { - UriBuilder.Query = _queryBuilder.ToString(); - } - - return UriBuilder.Uri; + UriBuilder.Query = _queryBuilder.ToString(); } + + return UriBuilder.Uri; } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/ErrorResult.cs b/src/Generated/Internal/ErrorResult.cs index 42938626..0ac8963c 100644 --- a/src/Generated/Internal/ErrorResult.cs +++ b/src/Generated/Internal/ErrorResult.cs @@ -5,19 +5,18 @@ using System.ClientModel; using System.ClientModel.Primitives; -namespace OpenAI -{ - internal class ErrorResult : ClientResult - { - private readonly PipelineResponse _response; - private readonly ClientResultException _exception; +namespace OpenAI; - public ErrorResult(PipelineResponse response, ClientResultException exception) : base(default, response) - { - _response = response; - _exception = exception; - } +internal class ErrorResult : ClientResult +{ + private readonly PipelineResponse _response; + private readonly ClientResultException _exception; - public override T Value => throw _exception; + public ErrorResult(PipelineResponse response, ClientResultException exception) : base(default, response) + { + _response = response; + _exception = exception; } -} + + public override T Value => throw _exception; +} \ No newline at end of file diff --git a/src/Generated/Internal/ModelSerializationExtensions.cs b/src/Generated/Internal/ModelSerializationExtensions.cs index d1334d37..efc25214 100644 --- a/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/src/Generated/Internal/ModelSerializationExtensions.cs @@ -10,390 +10,389 @@ using System.Text.Json; using System.Xml; -namespace OpenAI +namespace OpenAI; + +internal static class ModelSerializationExtensions { - internal static class ModelSerializationExtensions - { - internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly BinaryData SentinelValue = BinaryData.FromObjectAsJson("__EMPTY__"); + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly BinaryData SentinelValue = BinaryData.FromObjectAsJson("__EMPTY__"); - public static object GetObject(this JsonElement element) + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) { - switch (element.ValueKind) - { - case JsonValueKind.String: - return element.GetString(); - case JsonValueKind.Number: - if (element.TryGetInt32(out int intValue)) - { - return intValue; - } - if (element.TryGetInt64(out long longValue)) - { - return longValue; - } - return element.GetDouble(); - case JsonValueKind.True: - return true; - case JsonValueKind.False: - return false; - case JsonValueKind.Undefined: - case JsonValueKind.Null: - return null; - case JsonValueKind.Object: - var dictionary = new Dictionary(); - foreach (var jsonProperty in element.EnumerateObject()) - { - dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); - } - return dictionary; - case JsonValueKind.Array: - var list = new List(); - foreach (var item in element.EnumerateArray()) - { - list.Add(item.GetObject()); - } - return list.ToArray(); - default: - throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); - } + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); } + } - public static byte[] GetBytesFromBase64(this JsonElement element, string format) + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) { - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - - return format switch - { - "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), - "D" => element.GetBytesFromBase64(), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; + return null; } - public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + return format switch { - "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), - _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; - public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); - public static char GetChar(this JsonElement element) + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) { - if (element.ValueKind == JsonValueKind.String) - { - var text = element.GetString(); - if (text == null || text.Length != 1) - { - throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); - } - return text[0]; - } - else + var text = element.GetString(); + if (text == null || text.Length != 1) { - throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); } + return text[0]; } - - [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + else { - throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); } + } - public static string GetRequiredString(this JsonElement element) - { - var value = element.GetString(); - if (value == null) - { - throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); - } - return value; - } + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } - public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) { - writer.WriteStringValue(TypeFormatters.ToString(value, format)); + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } - public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) { - writer.WriteStringValue(TypeFormatters.ToString(value, format)); + writer.WriteNullValue(); + return; } - - public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + switch (format) { - writer.WriteStringValue(TypeFormatters.ToString(value, format)); + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); } + } - public static void WriteStringValue(this Utf8JsonWriter writer, char value) + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") { - writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } - public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) { - if (value == null) - { + case null: writer.WriteNullValue(); - return; - } - switch (format) - { - case "U": - writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); - break; - case "D": - writer.WriteBase64StringValue(value); - break; - default: - throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); - } + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); } + } - public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) - { - if (format != "U") - { - throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); - } - writer.WriteNumberValue(value.ToUnixTimeSeconds()); - } + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } - public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) - { - switch (value) - { - case null: - writer.WriteNullValue(); - break; - case IJsonModel jsonModel: - jsonModel.Write(writer, options ?? WireOptions); - break; - case byte[] bytes: - writer.WriteBase64StringValue(bytes); - break; - case BinaryData bytes0: - writer.WriteBase64StringValue(bytes0); - break; - case JsonElement json: - json.WriteTo(writer); - break; - case int i: - writer.WriteNumberValue(i); - break; - case decimal d: - writer.WriteNumberValue(d); - break; - case double d0: - if (double.IsNaN(d0)) - { - writer.WriteStringValue("NaN"); - } - else - { - writer.WriteNumberValue(d0); - } - break; - case float f: - writer.WriteNumberValue(f); - break; - case long l: - writer.WriteNumberValue(l); - break; - case string s: - writer.WriteStringValue(s); - break; - case bool b: - writer.WriteBooleanValue(b); - break; - case Guid g: - writer.WriteStringValue(g); - break; - case DateTimeOffset dateTimeOffset: - writer.WriteStringValue(dateTimeOffset, "O"); - break; - case DateTime dateTime: - writer.WriteStringValue(dateTime, "O"); - break; - case IEnumerable> enumerable: - writer.WriteStartObject(); - foreach (var pair in enumerable) - { - writer.WritePropertyName(pair.Key); - writer.WriteObjectValue(pair.Value, options); - } - writer.WriteEndObject(); - break; - case IEnumerable objectEnumerable: - writer.WriteStartArray(); - foreach (var item in objectEnumerable) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - break; - case TimeSpan timeSpan: - writer.WriteStringValue(timeSpan, "P"); - break; - default: - throw new NotSupportedException($"Not supported type {value.GetType()}"); - } - } + internal static bool IsSentinelValue(BinaryData value) + { + ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; + ReadOnlySpan valueSpan = value.ToMemory().Span; + return sentinelSpan.SequenceEqual(valueSpan); + } - public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) - { - writer.WriteObjectValue(value, options); - } + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; - internal static bool IsSentinelValue(BinaryData value) + public static string ToString(DateTime value, string format) => value.Kind switch { - ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; - ReadOnlySpan valueSpan = value.ToMemory().Span; - return sentinelSpan.SequenceEqual(valueSpan); - } + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; - internal static class TypeFormatters + public static string ToString(DateTimeOffset value, string format) => format switch { - private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; - public const string DefaultNumberFormat = "G"; + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; - public static string ToString(bool value) => value ? "true" : "false"; + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; - public static string ToString(DateTime value, string format) => value.Kind switch - { - DateTimeKind.Utc => ToString((DateTimeOffset)value, format), - _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") - }; + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; - public static string ToString(DateTimeOffset value, string format) => format switch - { - "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), - "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "R" => value.ToString("r", CultureInfo.InvariantCulture), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; - public static string ToString(TimeSpan value, string format) => format switch - { - "P" => XmlConvert.ToString(value), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - public static string ToString(byte[] value, string format) => format switch + int i = 0; + for (; i < numBase64Chars; i++) { - "U" => ToBase64UrlString(value), - "D" => Convert.ToBase64String(value), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - - public static string ToBase64UrlString(byte[] value) - { - int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; - int size = checked(numWholeOrPartialInputBlocks * 4); - char[] output = new char[size]; - - int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - - int i = 0; - for (; i < numBase64Chars; i++) + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else { - char ch = output[i]; - if (ch == '+') + if (ch == '/') { - output[i] = '-'; + output[i] = '_'; } else { - if (ch == '/') - { - output[i] = '_'; - } - else + if (ch == '=') { - if (ch == '=') - { - break; - } + break; } } } - - return new string(output, 0, i); } - public static byte[] FromBase64UrlString(string value) + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch { - int paddingCharsToAdd = (value.Length % 4) switch + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') { - 0 => 0, - 2 => 2, - 3 => 1, - _ => throw new InvalidOperationException("Malformed input") - }; - char[] output = new char[(value.Length + paddingCharsToAdd)]; - int i = 0; - for (; i < value.Length; i++) + output[i] = '+'; + } + else { - char ch = value[i]; - if (ch == '-') + if (ch == '_') { - output[i] = '+'; + output[i] = '/'; } else { - if (ch == '_') - { - output[i] = '/'; - } - else - { - output[i] = ch; - } + output[i] = ch; } } - - for (; i < output.Length; i++) - { - output[i] = '='; - } - - return Convert.FromBase64CharArray(output, 0, output.Length); } - public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch - { - "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), - _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) - }; - - public static TimeSpan ParseTimeSpan(string value, string format) => format switch + for (; i < output.Length; i++) { - "P" => XmlConvert.ToTimeSpan(value), - _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) - }; + output[i] = '='; + } - public static string ConvertToString(object value, string format = null) => value switch - { - null => "null", - string s => s, - bool b => ToString(b), - int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), - byte[] b0 when format != null => ToString(b0, format), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when format != null => ToString(dateTime, format), - TimeSpan timeSpan when format != null => ToString(timeSpan, format), - TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; + return Convert.FromBase64CharArray(output, 0, output.Length); } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/Optional.cs b/src/Generated/Internal/Optional.cs index 7b3fe480..c9f289bd 100644 --- a/src/Generated/Internal/Optional.cs +++ b/src/Generated/Internal/Optional.cs @@ -5,44 +5,43 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI +namespace OpenAI; + +internal static class Optional { - internal static class Optional + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) { - public static bool IsCollectionDefined(IEnumerable collection) - { - return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); - } - - public static bool IsCollectionDefined(IDictionary collection) - { - return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); - } - - public static bool IsCollectionDefined(IReadOnlyDictionary collection) - { - return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); - } - - public static bool IsDefined(T? value) - where T : struct - { - return value.HasValue; - } - - public static bool IsDefined(object value) - { - return value != null; - } - - public static bool IsDefined(JsonElement value) - { - return value.ValueKind != JsonValueKind.Undefined; - } - - public static bool IsDefined(string value) - { - return value != null; - } + return value != null; } -} +} \ No newline at end of file diff --git a/src/Generated/Internal/Utf8JsonBinaryContent.cs b/src/Generated/Internal/Utf8JsonBinaryContent.cs index 1f7d3068..bcac9576 100644 --- a/src/Generated/Internal/Utf8JsonBinaryContent.cs +++ b/src/Generated/Internal/Utf8JsonBinaryContent.cs @@ -8,45 +8,44 @@ using System.Threading; using System.Threading.Tasks; -namespace OpenAI +namespace OpenAI; + +internal class Utf8JsonBinaryContent : BinaryContent { - internal class Utf8JsonBinaryContent : BinaryContent + private readonly MemoryStream _stream; + private readonly BinaryContent _content; + + public Utf8JsonBinaryContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() { - private readonly MemoryStream _stream; - private readonly BinaryContent _content; - - public Utf8JsonBinaryContent() - { - _stream = new MemoryStream(); - _content = Create(_stream); - JsonWriter = new Utf8JsonWriter(_stream); - } - - public Utf8JsonWriter JsonWriter { get; } - - public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) - { - await JsonWriter.FlushAsync().ConfigureAwait(false); - await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); - } - - public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) - { - JsonWriter.Flush(); - _content.WriteTo(stream, cancellationToken); - } - - public override bool TryComputeLength(out long length) - { - length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; - return true; - } - - public override void Dispose() - { - JsonWriter.Dispose(); - _content.Dispose(); - _stream.Dispose(); - } + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); } -} +} \ No newline at end of file diff --git a/src/Generated/InternalAssistantMessageClient.cs b/src/Generated/InternalAssistantMessageClient.cs index 5ad0ce02..72a1f7dc 100644 --- a/src/Generated/InternalAssistantMessageClient.cs +++ b/src/Generated/InternalAssistantMessageClient.cs @@ -7,148 +7,147 @@ using System.ClientModel.Primitives; using System.Threading.Tasks; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +// Data plane generated sub-client. +internal partial class InternalAssistantMessageClient { - // Data plane generated sub-client. - internal partial class InternalAssistantMessageClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - public virtual ClientPipeline Pipeline => _pipeline; + public virtual ClientPipeline Pipeline => _pipeline; - protected InternalAssistantMessageClient() - { - } + protected InternalAssistantMessageClient() + { + } - public virtual async Task GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + public virtual async Task GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual ClientResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + public virtual ClientResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } + using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } - internal PipelineMessage CreateCreateMessageRequest(string threadId, BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateMessageRequest(string threadId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateGetMessagesRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + internal PipelineMessage CreateGetMessagesRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages", false); + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } - - internal PipelineMessage CreateGetMessageRequest(string threadId, string messageId, RequestOptions options) + if (order != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages/", false); - uri.AppendPath(messageId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("order", order, true); } - - internal PipelineMessage CreateModifyMessageRequest(string threadId, string messageId, BinaryContent content, RequestOptions options) + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages/", false); - uri.AppendPath(messageId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateDeleteMessageRequest(string threadId, string messageId, RequestOptions options) + if (before != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/messages/", false); - uri.AppendPath(messageId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("before", before, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateGetMessageRequest(string threadId, string messageId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages/", false); + uri.AppendPath(messageId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + internal PipelineMessage CreateModifyMessageRequest(string threadId, string messageId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages/", false); + uri.AppendPath(messageId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteMessageRequest(string threadId, string messageId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "DELETE"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages/", false); + uri.AppendPath(messageId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/InternalAssistantRunClient.cs b/src/Generated/InternalAssistantRunClient.cs index b079a8a5..f60e9345 100644 --- a/src/Generated/InternalAssistantRunClient.cs +++ b/src/Generated/InternalAssistantRunClient.cs @@ -7,260 +7,259 @@ using System.ClientModel.Primitives; using System.Threading.Tasks; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +// Data plane generated sub-client. +internal partial class InternalAssistantRunClient { - // Data plane generated sub-client. - internal partial class InternalAssistantRunClient + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected InternalAssistantRunClient() { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + } - public virtual ClientPipeline Pipeline => _pipeline; + public virtual async Task GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - protected InternalAssistantRunClient() - { - } + using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual async Task GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + public virtual ClientResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + public virtual async Task GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } + using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } - public virtual async Task GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + public virtual ClientResult GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } + using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } - public virtual ClientResult GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + internal PipelineMessage CreateCreateThreadAndRunRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/runs", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } + internal PipelineMessage CreateCreateRunRequest(string threadId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateCreateThreadAndRunRequest(BinaryContent content, RequestOptions options) + internal PipelineMessage CreateGetRunsRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs", false); + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/runs", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } - - internal PipelineMessage CreateCreateRunRequest(string threadId, BinaryContent content, RequestOptions options) + if (order != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("order", order, true); } - - internal PipelineMessage CreateGetRunsRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateGetRunRequest(string threadId, string runId, RequestOptions options) + if (before != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("before", before, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateModifyRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateGetRunRequest(string threadId, string runId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateModifyRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateCancelRunRequest(string threadId, string runId, RequestOptions options) + internal PipelineMessage CreateCancelRunRequest(string threadId, string runId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/cancel", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSubmitToolOutputsToRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/submit_tool_outputs", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetRunStepsRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/steps", false); + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } - - internal PipelineMessage CreateSubmitToolOutputsToRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) + if (order != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/submit_tool_outputs", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("order", order, true); } - - internal PipelineMessage CreateGetRunStepsRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/steps", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, RequestOptions options) + if (before != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - uri.AppendPath("/runs/", false); - uri.AppendPath(runId, true); - uri.AppendPath("/steps/", false); - uri.AppendPath(stepId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("before", before, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendPath("/steps/", false); + uri.AppendPath(stepId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/InternalAssistantThreadClient.cs b/src/Generated/InternalAssistantThreadClient.cs index 347ef4bd..4b695eba 100644 --- a/src/Generated/InternalAssistantThreadClient.cs +++ b/src/Generated/InternalAssistantThreadClient.cs @@ -5,93 +5,91 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Assistants -{ - // Data plane generated sub-client. - internal partial class InternalAssistantThreadClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; +namespace OpenAI.Assistants; - public virtual ClientPipeline Pipeline => _pipeline; +// Data plane generated sub-client. +internal partial class InternalAssistantThreadClient +{ + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - protected InternalAssistantThreadClient() - { - } + public virtual ClientPipeline Pipeline => _pipeline; - internal PipelineMessage CreateCreateThreadRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + protected InternalAssistantThreadClient() + { + } - internal PipelineMessage CreateGetThreadRequest(string threadId, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateCreateThreadRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateModifyThreadRequest(string threadId, BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } + internal PipelineMessage CreateGetThreadRequest(string threadId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateDeleteThreadRequest(string threadId, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/threads/", false); - uri.AppendPath(threadId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateModifyThreadRequest(string threadId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateDeleteThreadRequest(string threadId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "DELETE"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/InternalUploadsClient.cs b/src/Generated/InternalUploadsClient.cs index 4c6d033a..165cfd44 100644 --- a/src/Generated/InternalUploadsClient.cs +++ b/src/Generated/InternalUploadsClient.cs @@ -7,238 +7,237 @@ using System.ClientModel.Primitives; using System.Threading.Tasks; -namespace OpenAI.Files +namespace OpenAI.Files; + +// Data plane generated sub-client. +internal partial class InternalUploadsClient { - // Data plane generated sub-client. - internal partial class InternalUploadsClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - - public virtual ClientPipeline Pipeline => _pipeline; - - protected InternalUploadsClient() - { - } - - public virtual async Task> CreateUploadAsync(InternalCreateUploadRequest requestBody) - { - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using BinaryContent content = requestBody.ToBinaryContent(); - ClientResult result = await CreateUploadAsync(content, null).ConfigureAwait(false); - return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual ClientResult CreateUpload(InternalCreateUploadRequest requestBody) - { - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using BinaryContent content = requestBody.ToBinaryContent(); - ClientResult result = CreateUpload(content, null); - return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual async Task CreateUploadAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateUploadRequest(content, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public virtual ClientResult CreateUpload(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateUploadRequest(content, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - public virtual async Task> AddUploadPartAsync(string uploadId, InternalAddUploadPartRequest requestBody) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using MultipartFormDataBinaryContent content = requestBody.ToMultipartBinaryBody(); - ClientResult result = await AddUploadPartAsync(uploadId, content, content.ContentType, (RequestOptions)null).ConfigureAwait(false); - return ClientResult.FromValue(InternalUploadPart.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual ClientResult AddUploadPart(string uploadId, InternalAddUploadPartRequest requestBody) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using MultipartFormDataBinaryContent content = requestBody.ToMultipartBinaryBody(); - ClientResult result = AddUploadPart(uploadId, content, content.ContentType, (RequestOptions)null); - return ClientResult.FromValue(InternalUploadPart.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual async Task AddUploadPartAsync(string uploadId, BinaryContent content, string contentType, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateAddUploadPartRequest(uploadId, content, contentType, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public virtual ClientResult AddUploadPart(string uploadId, BinaryContent content, string contentType, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateAddUploadPartRequest(uploadId, content, contentType, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - public virtual async Task> CompleteUploadAsync(string uploadId, InternalCompleteUploadRequest requestBody) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using BinaryContent content = requestBody.ToBinaryContent(); - ClientResult result = await CompleteUploadAsync(uploadId, content, null).ConfigureAwait(false); - return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual ClientResult CompleteUpload(string uploadId, InternalCompleteUploadRequest requestBody) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using BinaryContent content = requestBody.ToBinaryContent(); - ClientResult result = CompleteUpload(uploadId, content, null); - return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual async Task CompleteUploadAsync(string uploadId, BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCompleteUploadRequest(uploadId, content, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public virtual ClientResult CompleteUpload(string uploadId, BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCompleteUploadRequest(uploadId, content, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - public virtual async Task> CancelUploadAsync(string uploadId) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - - ClientResult result = await CancelUploadAsync(uploadId, null).ConfigureAwait(false); - return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual ClientResult CancelUpload(string uploadId) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - - ClientResult result = CancelUpload(uploadId, null); - return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual async Task CancelUploadAsync(string uploadId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - - using PipelineMessage message = CreateCancelUploadRequest(uploadId, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public virtual ClientResult CancelUpload(string uploadId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); - - using PipelineMessage message = CreateCancelUploadRequest(uploadId, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal PipelineMessage CreateCreateUploadRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/uploads", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal PipelineMessage CreateAddUploadPartRequest(string uploadId, BinaryContent content, string contentType, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/uploads/", false); - uri.AppendPath(uploadId, true); - uri.AppendPath("/parts", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", contentType); - request.Content = content; - message.Apply(options); - return message; - } - - internal PipelineMessage CreateCompleteUploadRequest(string uploadId, BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/uploads/", false); - uri.AppendPath(uploadId, true); - uri.AppendPath("/complete", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal PipelineMessage CreateCancelUploadRequest(string uploadId, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/uploads/", false); - uri.AppendPath(uploadId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - } -} + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected InternalUploadsClient() + { + } + + public virtual async Task> CreateUploadAsync(InternalCreateUploadRequest requestBody) + { + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using BinaryContent content = requestBody.ToBinaryContent(); + ClientResult result = await CreateUploadAsync(content, null).ConfigureAwait(false); + return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual ClientResult CreateUpload(InternalCreateUploadRequest requestBody) + { + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using BinaryContent content = requestBody.ToBinaryContent(); + ClientResult result = CreateUpload(content, null); + return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual async Task CreateUploadAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateUploadRequest(content, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + public virtual ClientResult CreateUpload(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateUploadRequest(content, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } + + public virtual async Task> AddUploadPartAsync(string uploadId, InternalAddUploadPartRequest requestBody) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using MultipartFormDataBinaryContent content = requestBody.ToMultipartBinaryBody(); + ClientResult result = await AddUploadPartAsync(uploadId, content, content.ContentType, (RequestOptions)null).ConfigureAwait(false); + return ClientResult.FromValue(InternalUploadPart.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual ClientResult AddUploadPart(string uploadId, InternalAddUploadPartRequest requestBody) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using MultipartFormDataBinaryContent content = requestBody.ToMultipartBinaryBody(); + ClientResult result = AddUploadPart(uploadId, content, content.ContentType, (RequestOptions)null); + return ClientResult.FromValue(InternalUploadPart.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual async Task AddUploadPartAsync(string uploadId, BinaryContent content, string contentType, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateAddUploadPartRequest(uploadId, content, contentType, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + public virtual ClientResult AddUploadPart(string uploadId, BinaryContent content, string contentType, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateAddUploadPartRequest(uploadId, content, contentType, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } + + public virtual async Task> CompleteUploadAsync(string uploadId, InternalCompleteUploadRequest requestBody) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using BinaryContent content = requestBody.ToBinaryContent(); + ClientResult result = await CompleteUploadAsync(uploadId, content, null).ConfigureAwait(false); + return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual ClientResult CompleteUpload(string uploadId, InternalCompleteUploadRequest requestBody) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using BinaryContent content = requestBody.ToBinaryContent(); + ClientResult result = CompleteUpload(uploadId, content, null); + return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual async Task CompleteUploadAsync(string uploadId, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCompleteUploadRequest(uploadId, content, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + public virtual ClientResult CompleteUpload(string uploadId, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCompleteUploadRequest(uploadId, content, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } + + public virtual async Task> CancelUploadAsync(string uploadId) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + + ClientResult result = await CancelUploadAsync(uploadId, null).ConfigureAwait(false); + return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual ClientResult CancelUpload(string uploadId) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + + ClientResult result = CancelUpload(uploadId, null); + return ClientResult.FromValue(InternalUpload.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual async Task CancelUploadAsync(string uploadId, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + + using PipelineMessage message = CreateCancelUploadRequest(uploadId, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + public virtual ClientResult CancelUpload(string uploadId, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + + using PipelineMessage message = CreateCancelUploadRequest(uploadId, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } + + internal PipelineMessage CreateCreateUploadRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/uploads", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateAddUploadPartRequest(string uploadId, BinaryContent content, string contentType, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/uploads/", false); + uri.AppendPath(uploadId, true); + uri.AppendPath("/parts", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", contentType); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCompleteUploadRequest(string uploadId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/uploads/", false); + uri.AppendPath(uploadId, true); + uri.AppendPath("/complete", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCancelUploadRequest(string uploadId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/uploads/", false); + uri.AppendPath(uploadId, true); + uri.AppendPath("/cancel", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/LegacyCompletionClient.cs b/src/Generated/LegacyCompletionClient.cs index efb44faa..8e795d40 100644 --- a/src/Generated/LegacyCompletionClient.cs +++ b/src/Generated/LegacyCompletionClient.cs @@ -7,75 +7,74 @@ using System.ClientModel.Primitives; using System.Threading.Tasks; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +// Data plane generated sub-client. +internal partial class LegacyCompletionClient { - // Data plane generated sub-client. - internal partial class LegacyCompletionClient + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected LegacyCompletionClient() + { + } + + public virtual async Task> CreateCompletionAsync(InternalCreateCompletionRequest requestBody) { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - - public virtual ClientPipeline Pipeline => _pipeline; - - protected LegacyCompletionClient() - { - } - - public virtual async Task> CreateCompletionAsync(InternalCreateCompletionRequest requestBody) - { - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using BinaryContent content = requestBody.ToBinaryContent(); - ClientResult result = await CreateCompletionAsync(content, null).ConfigureAwait(false); - return ClientResult.FromValue(InternalCreateCompletionResponse.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual ClientResult CreateCompletion(InternalCreateCompletionRequest requestBody) - { - Argument.AssertNotNull(requestBody, nameof(requestBody)); - - using BinaryContent content = requestBody.ToBinaryContent(); - ClientResult result = CreateCompletion(content, null); - return ClientResult.FromValue(InternalCreateCompletionResponse.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - public virtual async Task CreateCompletionAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateCompletionRequest(content, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public virtual ClientResult CreateCompletion(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateCompletionRequest(content, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal PipelineMessage CreateCreateCompletionRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/completions", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using BinaryContent content = requestBody.ToBinaryContent(); + ClientResult result = await CreateCompletionAsync(content, null).ConfigureAwait(false); + return ClientResult.FromValue(InternalCreateCompletionResponse.FromResponse(result.GetRawResponse()), result.GetRawResponse()); + } + + public virtual ClientResult CreateCompletion(InternalCreateCompletionRequest requestBody) + { + Argument.AssertNotNull(requestBody, nameof(requestBody)); + + using BinaryContent content = requestBody.ToBinaryContent(); + ClientResult result = CreateCompletion(content, null); + return ClientResult.FromValue(InternalCreateCompletionResponse.FromResponse(result.GetRawResponse()), result.GetRawResponse()); } -} + + public virtual async Task CreateCompletionAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateCompletionRequest(content, options); + return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + public virtual ClientResult CreateCompletion(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateCompletionRequest(content, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } + + internal PipelineMessage CreateCreateCompletionRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/completions", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/ModelClient.cs b/src/Generated/ModelClient.cs index 9771fb0d..4911bbe2 100644 --- a/src/Generated/ModelClient.cs +++ b/src/Generated/ModelClient.cs @@ -7,71 +7,70 @@ using System.ClientModel.Primitives; using System.Threading.Tasks; -namespace OpenAI.Models -{ - // Data plane generated sub-client. - public partial class ModelClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; +namespace OpenAI.Models; - public virtual ClientPipeline Pipeline => _pipeline; +// Data plane generated sub-client. +public partial class ModelClient +{ + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - protected ModelClient() - { - } + public virtual ClientPipeline Pipeline => _pipeline; - internal PipelineMessage CreateGetModelsRequest(RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/models", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + protected ModelClient() + { + } - internal PipelineMessage CreateRetrieveModelRequest(string model, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/models/", false); - uri.AppendPath(model, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateGetModelsRequest(RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/models", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateDeleteModelRequest(string model, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/models/", false); - uri.AppendPath(model, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } + internal PipelineMessage CreateRetrieveModelRequest(string model, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/models/", false); + uri.AppendPath(model, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + internal PipelineMessage CreateDeleteModelRequest(string model, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "DELETE"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/models/", false); + uri.AppendPath(model, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/Models/Assistant.Serialization.cs b/src/Generated/Models/Assistant.Serialization.cs index 22f1b7a7..8d7371b1 100644 --- a/src/Generated/Models/Assistant.Serialization.cs +++ b/src/Generated/Models/Assistant.Serialization.cs @@ -8,389 +8,388 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class Assistant : IJsonModel { - public partial class Assistant : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Assistant)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (Name != null) { - throw new FormatException($"The model {nameof(Assistant)} does not support writing '{format}' format."); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + else { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WriteNull("name"); } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("description") != true) + { + if (Description != null) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + else { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WriteNull("description"); } - if (SerializedAdditionalRawData?.ContainsKey("name") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("instructions") != true) + { + if (Instructions != null) { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); } - if (SerializedAdditionalRawData?.ContainsKey("description") != true) + else { - if (Description != null) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - else - { - writer.WriteNull("description"); - } + writer.WriteNull("instructions"); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("instructions") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) { - if (Instructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - } - else - { - writer.WriteNull("instructions"); - } + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true) + else { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteNull("tool_resources"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + { + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { - if (ToolResources != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + else { - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + if (Temperature != null) { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + else { - if (NucleusSamplingFactor != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(NucleusSamplingFactor.Value); - } - else - { - writer.WriteNull("top_p"); - } + writer.WriteNull("temperature"); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + } + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + { + if (NucleusSamplingFactor != null) { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteObjectValue(ResponseFormat, options); - } - else - { - writer.WriteNull("response_format"); - } + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(NucleusSamplingFactor.Value); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + writer.WriteNull("top_p"); } - writer.WriteEndObject(); } - - Assistant IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (ResponseFormat != null) { - throw new FormatException($"The model {nameof(Assistant)} does not support reading '{format}' format."); + writer.WritePropertyName("response_format"u8); + writer.WriteObjectValue(ResponseFormat, options); + } + else + { + writer.WriteNull("response_format"); } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistant(document.RootElement, options); } - - internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - InternalAssistantObjectObject @object = default; - DateTimeOffset createdAt = default; - string name = default; - string description = default; - string model = default; - string instructions = default; - IReadOnlyList tools = default; - ToolResources toolResources = default; - IReadOnlyDictionary metadata = default; - float? temperature = default; - float? topP = default; - AssistantResponseFormat responseFormat = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - @object = new InternalAssistantObjectObject(property.Value.GetString()); continue; } - if (property.NameEquals("created_at"u8)) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; + JsonSerializer.Serialize(writer, document.RootElement); } - if (property.NameEquals("name"u8)) +#endif + } + } + writer.WriteEndObject(); + } + + Assistant IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Assistant)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistant(document.RootElement, options); + } + + internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalAssistantObjectObject @object = default; + DateTimeOffset createdAt = default; + string name = default; + string description = default; + string model = default; + string instructions = default; + IReadOnlyList tools = default; + ToolResources toolResources = default; + IReadOnlyDictionary metadata = default; + float? temperature = default; + float? topP = default; + AssistantResponseFormat responseFormat = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalAssistantObjectObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); + name = null; continue; } - if (property.NameEquals("description"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - description = null; - continue; - } - description = property.Value.GetString(); + description = null; continue; } - if (property.NameEquals("model"u8)) + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - model = property.Value.GetString(); + instructions = null; continue; } - if (property.NameEquals("instructions"u8)) + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); - continue; + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); } - if (property.NameEquals("tools"u8)) + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; + toolResources = null; continue; } - if (property.NameEquals("tool_resources"u8)) + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = ToolResources.DeserializeToolResources(property.Value, options); + metadata = new ChangeTrackingDictionary(); continue; } - if (property.NameEquals("metadata"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; + dictionary.Add(property0.Name, property0.Value.GetString()); } - if (property.NameEquals("temperature"u8)) + metadata = dictionary; + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); + temperature = null; continue; } - if (property.NameEquals("top_p"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); + topP = null; continue; } - if (property.NameEquals("response_format"u8)) + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + responseFormat = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new Assistant( - id, - @object, - createdAt, - name, - description, - model, - instructions, - tools, - toolResources, - metadata, - temperature, - topP, - responseFormat, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(Assistant)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new Assistant( + id, + @object, + createdAt, + name, + description, + model, + instructions, + tools, + toolResources, + metadata, + temperature, + topP, + responseFormat, + serializedAdditionalRawData); + } - Assistant IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistant(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Assistant)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Assistant)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + Assistant IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static Assistant FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAssistant(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistant(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Assistant)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static Assistant FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistant(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/Assistant.cs b/src/Generated/Models/Assistant.cs index db507e16..80db06f4 100644 --- a/src/Generated/Models/Assistant.cs +++ b/src/Generated/Models/Assistant.cs @@ -6,59 +6,58 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class Assistant { - public partial class Assistant + internal IDictionary SerializedAdditionalRawData { get; set; } + internal Assistant(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, IReadOnlyDictionary metadata) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal Assistant(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(model, nameof(model)); - Argument.AssertNotNull(tools, nameof(tools)); - - Id = id; - CreatedAt = createdAt; - Name = name; - Description = description; - Model = model; - Instructions = instructions; - Tools = tools.ToList(); - Metadata = metadata; - } - - internal Assistant(string id, InternalAssistantObjectObject @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, ToolResources toolResources, IReadOnlyDictionary metadata, float? temperature, float? nucleusSamplingFactor, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - Name = name; - Description = description; - Model = model; - Instructions = instructions; - Tools = tools; - ToolResources = toolResources; - Metadata = metadata; - Temperature = temperature; - NucleusSamplingFactor = nucleusSamplingFactor; - ResponseFormat = responseFormat; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal Assistant() - { - } + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(model, nameof(model)); + Argument.AssertNotNull(tools, nameof(tools)); + + Id = id; + CreatedAt = createdAt; + Name = name; + Description = description; + Model = model; + Instructions = instructions; + Tools = tools.ToList(); + Metadata = metadata; + } - public string Id { get; } + internal Assistant(string id, InternalAssistantObjectObject @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, ToolResources toolResources, IReadOnlyDictionary metadata, float? temperature, float? nucleusSamplingFactor, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + Name = name; + Description = description; + Model = model; + Instructions = instructions; + Tools = tools; + ToolResources = toolResources; + Metadata = metadata; + Temperature = temperature; + NucleusSamplingFactor = nucleusSamplingFactor; + ResponseFormat = responseFormat; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public DateTimeOffset CreatedAt { get; } - public string Name { get; } - public string Description { get; } - public string Model { get; } - public string Instructions { get; } - public IReadOnlyList Tools { get; } - public ToolResources ToolResources { get; } - public IReadOnlyDictionary Metadata { get; } - public float? Temperature { get; } + internal Assistant() + { } -} + + public string Id { get; } + + public DateTimeOffset CreatedAt { get; } + public string Name { get; } + public string Description { get; } + public string Model { get; } + public string Instructions { get; } + public IReadOnlyList Tools { get; } + public ToolResources ToolResources { get; } + public IReadOnlyDictionary Metadata { get; } + public float? Temperature { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantChatMessage.Serialization.cs b/src/Generated/Models/AssistantChatMessage.Serialization.cs index 89a7d76f..907fa076 100644 --- a/src/Generated/Models/AssistantChatMessage.Serialization.cs +++ b/src/Generated/Models/AssistantChatMessage.Serialization.cs @@ -8,146 +8,145 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class AssistantChatMessage : IJsonModel { - public partial class AssistantChatMessage : IJsonModel + AssistantChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - AssistantChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantChatMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{format}' format."); } - internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantChatMessage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string refusal = default; - string name = default; - IList toolCalls = default; - ChatFunctionCall functionCall = default; - ChatMessageRole role = default; - IList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static AssistantChatMessage DeserializeAssistantChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string refusal = default; + string name = default; + IList toolCalls = default; + ChatFunctionCall functionCall = default; + ChatMessageRole role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("refusal"u8)) { - if (property.NameEquals("refusal"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - refusal = null; - continue; - } - refusal = property.Value.GetString(); + refusal = null; continue; } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("tool_calls"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatToolCall.DeserializeChatToolCall(item, options)); - } - toolCalls = array; - continue; - } - if (property.NameEquals("function_call"u8)) + refusal = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - functionCall = null; - continue; - } - functionCall = ChatFunctionCall.DeserializeChatFunctionCall(property.Value, options); continue; } - if (property.NameEquals("role"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - role = property.Value.GetString().ToChatMessageRole(); - continue; + array.Add(ChatToolCall.DeserializeChatToolCall(item, options)); } - if (property.NameEquals("content"u8)) + toolCalls = array; + continue; + } + if (property.NameEquals("function_call"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - DeserializeContentValue(property, ref content); + functionCall = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + functionCall = ChatFunctionCall.DeserializeChatFunctionCall(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AssistantChatMessage( - role, - content ?? new ChangeTrackingList(), - serializedAdditionalRawData, - refusal, - name, - toolCalls ?? new ChangeTrackingList(), - functionCall); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("role"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support writing '{options.Format}' format."); + role = property.Value.GetString().ToChatMessageRole(); + continue; } - } - - AssistantChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("content"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistantChatMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{options.Format}' format."); + DeserializeContentValue(property, ref content); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AssistantChatMessage( + role, + content ?? new ChangeTrackingList(), + serializedAdditionalRawData, + refusal, + name, + toolCalls ?? new ChangeTrackingList(), + functionCall); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new AssistantChatMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAssistantChatMessage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support writing '{options.Format}' format."); } + } + + AssistantChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantChatMessage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new AssistantChatMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantChatMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantChatMessage.cs b/src/Generated/Models/AssistantChatMessage.cs index 35522b2c..247dd458 100644 --- a/src/Generated/Models/AssistantChatMessage.cs +++ b/src/Generated/Models/AssistantChatMessage.cs @@ -5,18 +5,17 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class AssistantChatMessage : ChatMessage { - public partial class AssistantChatMessage : ChatMessage + internal AssistantChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall) : base(role, content, serializedAdditionalRawData) { - internal AssistantChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall) : base(role, content, serializedAdditionalRawData) - { - Refusal = refusal; - ParticipantName = participantName; - ToolCalls = toolCalls; - FunctionCall = functionCall; - } - - public string Refusal { get; set; } + Refusal = refusal; + ParticipantName = participantName; + ToolCalls = toolCalls; + FunctionCall = functionCall; } -} + + public string Refusal { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantCollectionOrder.cs b/src/Generated/Models/AssistantCollectionOrder.cs index 2b25b845..de26f2e6 100644 --- a/src/Generated/Models/AssistantCollectionOrder.cs +++ b/src/Generated/Models/AssistantCollectionOrder.cs @@ -5,29 +5,28 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct AssistantCollectionOrder : IEquatable { - public readonly partial struct AssistantCollectionOrder : IEquatable + private readonly string _value; + + public AssistantCollectionOrder(string value) { - private readonly string _value; - - public AssistantCollectionOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AscendingValue = "asc"; - private const string DescendingValue = "desc"; - public static bool operator ==(AssistantCollectionOrder left, AssistantCollectionOrder right) => left.Equals(right); - public static bool operator !=(AssistantCollectionOrder left, AssistantCollectionOrder right) => !left.Equals(right); - public static implicit operator AssistantCollectionOrder(string value) => new AssistantCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AssistantCollectionOrder other && Equals(other); - public bool Equals(AssistantCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AscendingValue = "asc"; + private const string DescendingValue = "desc"; + public static bool operator ==(AssistantCollectionOrder left, AssistantCollectionOrder right) => left.Equals(right); + public static bool operator !=(AssistantCollectionOrder left, AssistantCollectionOrder right) => !left.Equals(right); + public static implicit operator AssistantCollectionOrder(string value) => new AssistantCollectionOrder(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantCollectionOrder other && Equals(other); + public bool Equals(AssistantCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantCreationOptions.Serialization.cs b/src/Generated/Models/AssistantCreationOptions.Serialization.cs index 31be626b..e81044d9 100644 --- a/src/Generated/Models/AssistantCreationOptions.Serialization.cs +++ b/src/Generated/Models/AssistantCreationOptions.Serialization.cs @@ -8,356 +8,355 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantCreationOptions : IJsonModel { - public partial class AssistantCreationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + if (Name != null) { - throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + else { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); + writer.WriteNull("name"); } - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + } + if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) + { + if (Description != null) { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); } - if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) + else { - if (Description != null) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - else - { - writer.WriteNull("description"); - } + writer.WriteNull("description"); } - if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(Instructions)) + } + if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(Instructions)) + { + if (Instructions != null) { - if (Instructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - } - else - { - writer.WriteNull("instructions"); - } + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + else { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteNull("instructions"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + else { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } + writer.WriteNull("tool_resources"); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (NucleusSamplingFactor != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(NucleusSamplingFactor.Value); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("top_p"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + else { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteObjectValue(ResponseFormat, options); - } - else - { - writer.WriteNull("response_format"); - } + writer.WriteNull("metadata"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + { + if (NucleusSamplingFactor != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(NucleusSamplingFactor.Value); + } + else + { + writer.WriteNull("top_p"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) { - foreach (var item in SerializedAdditionalRawData) + writer.WritePropertyName("response_format"u8); + writer.WriteObjectValue(ResponseFormat, options); + } + else + { + writer.WriteNull("response_format"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AssistantCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AssistantCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantCreationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support reading '{format}' format."); } - internal static AssistantCreationOptions DeserializeAssistantCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantCreationOptions(document.RootElement, options); + } + + internal static AssistantCreationOptions DeserializeAssistantCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string model = default; + string name = default; + string description = default; + string instructions = default; + IList tools = default; + ToolResources toolResources = default; + IDictionary metadata = default; + float? temperature = default; + float? topP = default; + AssistantResponseFormat responseFormat = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) { - return null; + model = property.Value.GetString(); + continue; } - string model = default; - string name = default; - string description = default; - string instructions = default; - IList tools = default; - ToolResources toolResources = default; - IDictionary metadata = default; - float? temperature = default; - float? topP = default; - AssistantResponseFormat responseFormat = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("model"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - model = property.Value.GetString(); + name = null; continue; } - if (property.NameEquals("name"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); + description = null; continue; } - if (property.NameEquals("description"u8)) + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - description = null; - continue; - } - description = property.Value.GetString(); + instructions = null; continue; } - if (property.NameEquals("instructions"u8)) + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); continue; } - if (property.NameEquals("tools"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); } - if (property.NameEquals("tool_resources"u8)) + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + toolResources = null; continue; } - if (property.NameEquals("metadata"u8)) + toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (property.NameEquals("temperature"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; + dictionary.Add(property0.Name, property0.Value.GetString()); } - if (property.NameEquals("top_p"u8)) + metadata = dictionary; + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); + temperature = null; continue; } - if (property.NameEquals("response_format"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + topP = null; continue; } - if (true) + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + responseFormat = null; + continue; } + responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AssistantCreationOptions( - model, - name, - description, - instructions, - tools ?? new ChangeTrackingList(), - toolResources, - metadata ?? new ChangeTrackingDictionary(), - temperature, - topP, - responseFormat, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AssistantCreationOptions( + model, + name, + description, + instructions, + tools ?? new ChangeTrackingList(), + toolResources, + metadata ?? new ChangeTrackingDictionary(), + temperature, + topP, + responseFormat, + serializedAdditionalRawData); + } - AssistantCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistantCreationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + AssistantCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static AssistantCreationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAssistantCreationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantCreationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static AssistantCreationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantCreationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantCreationOptions.cs b/src/Generated/Models/AssistantCreationOptions.cs index 9e0ed5af..00c2a8e1 100644 --- a/src/Generated/Models/AssistantCreationOptions.cs +++ b/src/Generated/Models/AssistantCreationOptions.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantCreationOptions { - public partial class AssistantCreationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal AssistantCreationOptions(string model, string name, string description, string instructions, IList tools, ToolResources toolResources, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) - { - Model = model; - Name = name; - Description = description; - Instructions = instructions; - Tools = tools; - ToolResources = toolResources; - Metadata = metadata; - Temperature = temperature; - NucleusSamplingFactor = nucleusSamplingFactor; - ResponseFormat = responseFormat; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public string Name { get; set; } - public string Description { get; set; } - public string Instructions { get; set; } - public IDictionary Metadata { get; set; } - public float? Temperature { get; set; } + internal AssistantCreationOptions(string model, string name, string description, string instructions, IList tools, ToolResources toolResources, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + { + Model = model; + Name = name; + Description = description; + Instructions = instructions; + Tools = tools; + ToolResources = toolResources; + Metadata = metadata; + Temperature = temperature; + NucleusSamplingFactor = nucleusSamplingFactor; + ResponseFormat = responseFormat; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public string Name { get; set; } + public string Description { get; set; } + public string Instructions { get; set; } + public IDictionary Metadata { get; set; } + public float? Temperature { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantDeletionResult.Serialization.cs b/src/Generated/Models/AssistantDeletionResult.Serialization.cs index 85b760cd..f09ef099 100644 --- a/src/Generated/Models/AssistantDeletionResult.Serialization.cs +++ b/src/Generated/Models/AssistantDeletionResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantDeletionResult : IJsonModel { - public partial class AssistantDeletionResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(AssistantId); - } - if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) - { - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(AssistantId); + } + if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) + { + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AssistantDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AssistantDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantDeletionResult(document.RootElement, options); + throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support reading '{format}' format."); } - internal static AssistantDeletionResult DeserializeAssistantDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantDeletionResult(document.RootElement, options); + } + + internal static AssistantDeletionResult DeserializeAssistantDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalDeleteAssistantResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - bool deleted = default; - InternalDeleteAssistantResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("deleted"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalDeleteAssistantResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + deleted = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AssistantDeletionResult(id, deleted, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support writing '{options.Format}' format."); + @object = new InternalDeleteAssistantResponseObject(property.Value.GetString()); + continue; } - } - - AssistantDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistantDeletionResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AssistantDeletionResult(id, deleted, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static AssistantDeletionResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAssistantDeletionResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support writing '{options.Format}' format."); } + } + + AssistantDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantDeletionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantDeletionResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static AssistantDeletionResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantDeletionResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantDeletionResult.cs b/src/Generated/Models/AssistantDeletionResult.cs index 7736dd66..fcdfe72f 100644 --- a/src/Generated/Models/AssistantDeletionResult.cs +++ b/src/Generated/Models/AssistantDeletionResult.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantDeletionResult { - public partial class AssistantDeletionResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal AssistantDeletionResult(string assistantId, bool deleted) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal AssistantDeletionResult(string assistantId, bool deleted) - { - Argument.AssertNotNull(assistantId, nameof(assistantId)); + Argument.AssertNotNull(assistantId, nameof(assistantId)); - AssistantId = assistantId; - Deleted = deleted; - } + AssistantId = assistantId; + Deleted = deleted; + } - internal AssistantDeletionResult(string assistantId, bool deleted, InternalDeleteAssistantResponseObject @object, IDictionary serializedAdditionalRawData) - { - AssistantId = assistantId; - Deleted = deleted; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal AssistantDeletionResult(string assistantId, bool deleted, InternalDeleteAssistantResponseObject @object, IDictionary serializedAdditionalRawData) + { + AssistantId = assistantId; + Deleted = deleted; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal AssistantDeletionResult() - { - } - public bool Deleted { get; } + internal AssistantDeletionResult() + { } -} + public bool Deleted { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantModificationOptions.Serialization.cs b/src/Generated/Models/AssistantModificationOptions.Serialization.cs index 185f0d9b..41e7df33 100644 --- a/src/Generated/Models/AssistantModificationOptions.Serialization.cs +++ b/src/Generated/Models/AssistantModificationOptions.Serialization.cs @@ -8,356 +8,355 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantModificationOptions : IJsonModel { - public partial class AssistantModificationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + if (Name != null) { - throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + else { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); + writer.WriteNull("name"); } - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + } + if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) + { + if (Description != null) { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); } - if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) + else { - if (Description != null) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - else - { - writer.WriteNull("description"); - } + writer.WriteNull("description"); } - if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(Instructions)) + } + if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(Instructions)) + { + if (Instructions != null) { - if (Instructions != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - } - else - { - writer.WriteNull("instructions"); - } + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(DefaultTools)) + else { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in DefaultTools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteNull("instructions"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(DefaultTools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in DefaultTools) { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + else { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } + writer.WriteNull("tool_resources"); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (NucleusSamplingFactor != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(NucleusSamplingFactor.Value); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("top_p"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + else { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteObjectValue(ResponseFormat, options); - } - else - { - writer.WriteNull("response_format"); - } + writer.WriteNull("metadata"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + { + if (NucleusSamplingFactor != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(NucleusSamplingFactor.Value); + } + else + { + writer.WriteNull("top_p"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) { - foreach (var item in SerializedAdditionalRawData) + writer.WritePropertyName("response_format"u8); + writer.WriteObjectValue(ResponseFormat, options); + } + else + { + writer.WriteNull("response_format"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AssistantModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AssistantModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantModificationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support reading '{format}' format."); } - internal static AssistantModificationOptions DeserializeAssistantModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantModificationOptions(document.RootElement, options); + } + + internal static AssistantModificationOptions DeserializeAssistantModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string model = default; + string name = default; + string description = default; + string instructions = default; + IList tools = default; + ToolResources toolResources = default; + IDictionary metadata = default; + float? temperature = default; + float? topP = default; + AssistantResponseFormat responseFormat = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) { - return null; + model = property.Value.GetString(); + continue; } - string model = default; - string name = default; - string description = default; - string instructions = default; - IList tools = default; - ToolResources toolResources = default; - IDictionary metadata = default; - float? temperature = default; - float? topP = default; - AssistantResponseFormat responseFormat = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("model"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - model = property.Value.GetString(); + name = null; continue; } - if (property.NameEquals("name"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); + description = null; continue; } - if (property.NameEquals("description"u8)) + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - description = null; - continue; - } - description = property.Value.GetString(); + instructions = null; continue; } - if (property.NameEquals("instructions"u8)) + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); continue; } - if (property.NameEquals("tools"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); } - if (property.NameEquals("tool_resources"u8)) + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + toolResources = null; continue; } - if (property.NameEquals("metadata"u8)) + toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (property.NameEquals("temperature"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; + dictionary.Add(property0.Name, property0.Value.GetString()); } - if (property.NameEquals("top_p"u8)) + metadata = dictionary; + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); + temperature = null; continue; } - if (property.NameEquals("response_format"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + topP = null; continue; } - if (true) + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + responseFormat = null; + continue; } + responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AssistantModificationOptions( - model, - name, - description, - instructions, - tools ?? new ChangeTrackingList(), - toolResources, - metadata ?? new ChangeTrackingDictionary(), - temperature, - topP, - responseFormat, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AssistantModificationOptions( + model, + name, + description, + instructions, + tools ?? new ChangeTrackingList(), + toolResources, + metadata ?? new ChangeTrackingDictionary(), + temperature, + topP, + responseFormat, + serializedAdditionalRawData); + } - AssistantModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistantModificationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + AssistantModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static AssistantModificationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAssistantModificationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantModificationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantModificationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static AssistantModificationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantModificationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantModificationOptions.cs b/src/Generated/Models/AssistantModificationOptions.cs index baa7fed1..1d3e3d18 100644 --- a/src/Generated/Models/AssistantModificationOptions.cs +++ b/src/Generated/Models/AssistantModificationOptions.cs @@ -5,35 +5,34 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantModificationOptions { - public partial class AssistantModificationOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public AssistantModificationOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public AssistantModificationOptions() - { - DefaultTools = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } + DefaultTools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } - internal AssistantModificationOptions(string model, string name, string description, string instructions, IList defaultTools, ToolResources toolResources, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) - { - Model = model; - Name = name; - Description = description; - Instructions = instructions; - DefaultTools = defaultTools; - ToolResources = toolResources; - Metadata = metadata; - Temperature = temperature; - NucleusSamplingFactor = nucleusSamplingFactor; - ResponseFormat = responseFormat; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public string Name { get; set; } - public string Description { get; set; } - public string Instructions { get; set; } - public IDictionary Metadata { get; set; } - public float? Temperature { get; set; } + internal AssistantModificationOptions(string model, string name, string description, string instructions, IList defaultTools, ToolResources toolResources, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + { + Model = model; + Name = name; + Description = description; + Instructions = instructions; + DefaultTools = defaultTools; + ToolResources = toolResources; + Metadata = metadata; + Temperature = temperature; + NucleusSamplingFactor = nucleusSamplingFactor; + ResponseFormat = responseFormat; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public string Name { get; set; } + public string Description { get; set; } + public string Instructions { get; set; } + public IDictionary Metadata { get; set; } + public float? Temperature { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantResponseFormat.Serialization.cs b/src/Generated/Models/AssistantResponseFormat.Serialization.cs index f2fa4d9f..86d408ef 100644 --- a/src/Generated/Models/AssistantResponseFormat.Serialization.cs +++ b/src/Generated/Models/AssistantResponseFormat.Serialization.cs @@ -7,10 +7,9 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(InternalUnknownAssistantResponseFormat))] +public partial class AssistantResponseFormat : IJsonModel { - [PersistableModelProxy(typeof(InternalUnknownAssistantResponseFormat))] - public partial class AssistantResponseFormat : IJsonModel - { - } -} +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantResponseFormat.cs b/src/Generated/Models/AssistantResponseFormat.cs index 3490f8a5..93f21a5a 100644 --- a/src/Generated/Models/AssistantResponseFormat.cs +++ b/src/Generated/Models/AssistantResponseFormat.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public abstract partial class AssistantResponseFormat { - public abstract partial class AssistantResponseFormat + internal IDictionary SerializedAdditionalRawData { get; set; } + protected AssistantResponseFormat() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected AssistantResponseFormat() - { - } - - internal AssistantResponseFormat(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal AssistantResponseFormat(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantThread.Serialization.cs b/src/Generated/Models/AssistantThread.Serialization.cs index 45e72b9b..f31b173f 100644 --- a/src/Generated/Models/AssistantThread.Serialization.cs +++ b/src/Generated/Models/AssistantThread.Serialization.cs @@ -8,211 +8,210 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantThread : IJsonModel { - public partial class AssistantThread : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantThread)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(AssistantThread)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true) + { + if (ToolResources != null) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + else { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WriteNull("tool_resources"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + { + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { - if (ToolResources != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + else { - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AssistantThread IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AssistantThread IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantThread)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantThread(document.RootElement, options); + throw new FormatException($"The model {nameof(AssistantThread)} does not support reading '{format}' format."); } - internal static AssistantThread DeserializeAssistantThread(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantThread(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static AssistantThread DeserializeAssistantThread(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalThreadObjectObject @object = default; + DateTimeOffset createdAt = default; + ToolResources toolResources = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalThreadObjectObject @object = default; - DateTimeOffset createdAt = default; - ToolResources toolResources = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalThreadObjectObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("tool_resources"u8)) + @object = new InternalThreadObjectObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + toolResources = null; continue; } - if (property.NameEquals("metadata"u8)) + toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; + metadata = new ChangeTrackingDictionary(); continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AssistantThread( - id, - @object, - createdAt, - toolResources, - metadata, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AssistantThread)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AssistantThread( + id, + @object, + createdAt, + toolResources, + metadata, + serializedAdditionalRawData); + } - AssistantThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistantThread(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AssistantThread)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantThread)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + AssistantThread IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static AssistantThread FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAssistantThread(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantThread(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantThread)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static AssistantThread FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantThread(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/AssistantThread.cs b/src/Generated/Models/AssistantThread.cs index 6cec49e4..38ae05de 100644 --- a/src/Generated/Models/AssistantThread.cs +++ b/src/Generated/Models/AssistantThread.cs @@ -5,38 +5,37 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class AssistantThread { - public partial class AssistantThread + internal IDictionary SerializedAdditionalRawData { get; set; } + internal AssistantThread(string id, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + CreatedAt = createdAt; + ToolResources = toolResources; + Metadata = metadata; + } + + internal AssistantThread(string id, InternalThreadObjectObject @object, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal AssistantThread(string id, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - CreatedAt = createdAt; - ToolResources = toolResources; - Metadata = metadata; - } - - internal AssistantThread(string id, InternalThreadObjectObject @object, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - ToolResources = toolResources; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal AssistantThread() - { - } - - public string Id { get; } - - public DateTimeOffset CreatedAt { get; } - public IReadOnlyDictionary Metadata { get; } + Id = id; + Object = @object; + CreatedAt = createdAt; + ToolResources = toolResources; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal AssistantThread() + { + } + + public string Id { get; } + + public DateTimeOffset CreatedAt { get; } + public IReadOnlyDictionary Metadata { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranscription.Serialization.cs b/src/Generated/Models/AudioTranscription.Serialization.cs index d08be5d1..1de08e1c 100644 --- a/src/Generated/Models/AudioTranscription.Serialization.cs +++ b/src/Generated/Models/AudioTranscription.Serialization.cs @@ -8,210 +8,209 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranscription : IJsonModel { - public partial class AudioTranscription : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranscription)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(AudioTranscription)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("task") != true) - { - writer.WritePropertyName("task"u8); - writer.WriteStringValue(Task.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("language") != true) - { - writer.WritePropertyName("language"u8); - writer.WriteStringValue(Language); - } - if (SerializedAdditionalRawData?.ContainsKey("duration") != true) - { - writer.WritePropertyName("duration"u8); - writer.WriteNumberValue(Convert.ToDouble(Duration.Value.ToString("s\\.FFF"))); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("task") != true) + { + writer.WritePropertyName("task"u8); + writer.WriteStringValue(Task.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("language") != true) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (SerializedAdditionalRawData?.ContainsKey("duration") != true) + { + writer.WritePropertyName("duration"u8); + writer.WriteNumberValue(Convert.ToDouble(Duration.Value.ToString("s\\.FFF"))); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData?.ContainsKey("words") != true && Optional.IsCollectionDefined(Words)) + { + writer.WritePropertyName("words"u8); + writer.WriteStartArray(); + foreach (var item in Words) { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("words") != true && Optional.IsCollectionDefined(Words)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("segments") != true && Optional.IsCollectionDefined(Segments)) + { + writer.WritePropertyName("segments"u8); + writer.WriteStartArray(); + foreach (var item in Segments) { - writer.WritePropertyName("words"u8); - writer.WriteStartArray(); - foreach (var item in Words) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("segments") != true && Optional.IsCollectionDefined(Segments)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("segments"u8); - writer.WriteStartArray(); - foreach (var item in Segments) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AudioTranscription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AudioTranscription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranscription)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAudioTranscription(document.RootElement, options); + throw new FormatException($"The model {nameof(AudioTranscription)} does not support reading '{format}' format."); } - internal static AudioTranscription DeserializeAudioTranscription(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAudioTranscription(document.RootElement, options); + } + + internal static AudioTranscription DeserializeAudioTranscription(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateTranscriptionResponseVerboseJsonTask task = default; + string language = default; + TimeSpan? duration = default; + string text = default; + IReadOnlyList words = default; + IReadOnlyList segments = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("task"u8)) { - return null; + task = new InternalCreateTranscriptionResponseVerboseJsonTask(property.Value.GetString()); + continue; } - InternalCreateTranscriptionResponseVerboseJsonTask task = default; - string language = default; - TimeSpan? duration = default; - string text = default; - IReadOnlyList words = default; - IReadOnlyList segments = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("language"u8)) { - if (property.NameEquals("task"u8)) - { - task = new InternalCreateTranscriptionResponseVerboseJsonTask(property.Value.GetString()); - continue; - } - if (property.NameEquals("language"u8)) - { - language = property.Value.GetString(); - continue; - } - if (property.NameEquals("duration"u8)) - { - duration = TimeSpan.FromSeconds(property.Value.GetDouble()); - continue; - } - if (property.NameEquals("text"u8)) + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("duration"u8)) + { + duration = TimeSpan.FromSeconds(property.Value.GetDouble()); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("words"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - text = property.Value.GetString(); continue; } - if (property.NameEquals("words"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(TranscribedWord.DeserializeTranscribedWord(item, options)); - } - words = array; - continue; + array.Add(TranscribedWord.DeserializeTranscribedWord(item, options)); } - if (property.NameEquals("segments"u8)) + words = array; + continue; + } + if (property.NameEquals("segments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(TranscribedSegment.DeserializeTranscribedSegment(item, options)); - } - segments = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(TranscribedSegment.DeserializeTranscribedSegment(item, options)); } + segments = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AudioTranscription( - task, - language, - duration, - text, - words ?? new ChangeTrackingList(), - segments ?? new ChangeTrackingList(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AudioTranscription)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AudioTranscription( + task, + language, + duration, + text, + words ?? new ChangeTrackingList(), + segments ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } - AudioTranscription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAudioTranscription(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AudioTranscription)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AudioTranscription)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + AudioTranscription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAudioTranscription(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AudioTranscription)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranscription.cs b/src/Generated/Models/AudioTranscription.cs index ce982452..0240b699 100644 --- a/src/Generated/Models/AudioTranscription.cs +++ b/src/Generated/Models/AudioTranscription.cs @@ -5,41 +5,40 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranscription { - public partial class AudioTranscription + internal IDictionary SerializedAdditionalRawData { get; set; } + internal AudioTranscription(string language, TimeSpan? duration, string text) + { + Argument.AssertNotNull(language, nameof(language)); + Argument.AssertNotNull(text, nameof(text)); + + Language = language; + Duration = duration; + Text = text; + Words = new ChangeTrackingList(); + Segments = new ChangeTrackingList(); + } + + internal AudioTranscription(InternalCreateTranscriptionResponseVerboseJsonTask task, string language, TimeSpan? duration, string text, IReadOnlyList words, IReadOnlyList segments, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal AudioTranscription(string language, TimeSpan? duration, string text) - { - Argument.AssertNotNull(language, nameof(language)); - Argument.AssertNotNull(text, nameof(text)); - - Language = language; - Duration = duration; - Text = text; - Words = new ChangeTrackingList(); - Segments = new ChangeTrackingList(); - } - - internal AudioTranscription(InternalCreateTranscriptionResponseVerboseJsonTask task, string language, TimeSpan? duration, string text, IReadOnlyList words, IReadOnlyList segments, IDictionary serializedAdditionalRawData) - { - Task = task; - Language = language; - Duration = duration; - Text = text; - Words = words; - Segments = segments; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal AudioTranscription() - { - } - - public string Language { get; } - public string Text { get; } - public IReadOnlyList Words { get; } - public IReadOnlyList Segments { get; } + Task = task; + Language = language; + Duration = duration; + Text = text; + Words = words; + Segments = segments; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal AudioTranscription() + { + } + + public string Language { get; } + public string Text { get; } + public IReadOnlyList Words { get; } + public IReadOnlyList Segments { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranscriptionFormat.Serialization.cs b/src/Generated/Models/AudioTranscriptionFormat.Serialization.cs index 699760d2..8246955f 100644 --- a/src/Generated/Models/AudioTranscriptionFormat.Serialization.cs +++ b/src/Generated/Models/AudioTranscriptionFormat.Serialization.cs @@ -4,28 +4,27 @@ using System; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal static partial class AudioTranscriptionFormatExtensions { - internal static partial class AudioTranscriptionFormatExtensions + public static string ToSerialString(this AudioTranscriptionFormat value) => value switch { - public static string ToSerialString(this AudioTranscriptionFormat value) => value switch - { - AudioTranscriptionFormat.Simple => "json", - AudioTranscriptionFormat.Text => "text", - AudioTranscriptionFormat.Srt => "srt", - AudioTranscriptionFormat.Verbose => "verbose_json", - AudioTranscriptionFormat.Vtt => "vtt", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranscriptionFormat value.") - }; + AudioTranscriptionFormat.Simple => "json", + AudioTranscriptionFormat.Text => "text", + AudioTranscriptionFormat.Srt => "srt", + AudioTranscriptionFormat.Verbose => "verbose_json", + AudioTranscriptionFormat.Vtt => "vtt", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranscriptionFormat value.") + }; - public static AudioTranscriptionFormat ToAudioTranscriptionFormat(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "json")) return AudioTranscriptionFormat.Simple; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "text")) return AudioTranscriptionFormat.Text; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "srt")) return AudioTranscriptionFormat.Srt; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "verbose_json")) return AudioTranscriptionFormat.Verbose; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "vtt")) return AudioTranscriptionFormat.Vtt; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranscriptionFormat value."); - } + public static AudioTranscriptionFormat ToAudioTranscriptionFormat(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "json")) return AudioTranscriptionFormat.Simple; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "text")) return AudioTranscriptionFormat.Text; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "srt")) return AudioTranscriptionFormat.Srt; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "verbose_json")) return AudioTranscriptionFormat.Verbose; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "vtt")) return AudioTranscriptionFormat.Vtt; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranscriptionFormat value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranscriptionOptions.Serialization.cs b/src/Generated/Models/AudioTranscriptionOptions.Serialization.cs index cebd9176..2a5780c5 100644 --- a/src/Generated/Models/AudioTranscriptionOptions.Serialization.cs +++ b/src/Generated/Models/AudioTranscriptionOptions.Serialization.cs @@ -9,296 +9,295 @@ using System.IO; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranscriptionOptions : IJsonModel { - public partial class AudioTranscriptionOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file") != true) - { - writer.WritePropertyName("file"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file") != true) + { + writer.WritePropertyName("file"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(File); #else - using (JsonDocument document = JsonDocument.Parse(File)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("language") != true && Optional.IsDefined(Language)) - { - writer.WritePropertyName("language"u8); - writer.WriteStringValue(Language); - } - if (SerializedAdditionalRawData?.ContainsKey("prompt") != true && Optional.IsDefined(Prompt)) - { - writer.WritePropertyName("prompt"u8); - writer.WriteStringValue(Prompt); - } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) - { - writer.WritePropertyName("response_format"u8); - writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); - } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + using (JsonDocument document = JsonDocument.Parse(File)) { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData?.ContainsKey("timestamp_granularities") != true && Optional.IsCollectionDefined(TimestampGranularities)) +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("language") != true && Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (SerializedAdditionalRawData?.ContainsKey("prompt") != true && Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("timestamp_granularities") != true && Optional.IsCollectionDefined(TimestampGranularities)) + { + writer.WritePropertyName("timestamp_granularities"u8); + writer.WriteStartArray(); + foreach (var item in TimestampGranularities) { - writer.WritePropertyName("timestamp_granularities"u8); - writer.WriteStartArray(); - foreach (var item in TimestampGranularities) + if (item == null) { - if (item == null) - { - writer.WriteNullValue(); - continue; - } + writer.WriteNullValue(); + continue; + } #if NET6_0_OR_GREATER writer.WriteRawValue(item); #else - using (JsonDocument document = JsonDocument.Parse(item)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - writer.WriteEndArray(); +#endif } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AudioTranscriptionOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AudioTranscriptionOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAudioTranscriptionOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support reading '{format}' format."); } - internal static AudioTranscriptionOptions DeserializeAudioTranscriptionOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAudioTranscriptionOptions(document.RootElement, options); + } + + internal static AudioTranscriptionOptions DeserializeAudioTranscriptionOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData file = default; + InternalCreateTranscriptionRequestModel model = default; + string language = default; + string prompt = default; + AudioTranscriptionFormat? responseFormat = default; + float? temperature = default; + IList timestampGranularities = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file"u8)) { - return null; + file = BinaryData.FromString(property.Value.GetRawText()); + continue; } - BinaryData file = default; - InternalCreateTranscriptionRequestModel model = default; - string language = default; - string prompt = default; - AudioTranscriptionFormat? responseFormat = default; - float? temperature = default; - IList timestampGranularities = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("model"u8)) { - if (property.NameEquals("file"u8)) - { - file = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("model"u8)) - { - model = new InternalCreateTranscriptionRequestModel(property.Value.GetString()); - continue; - } - if (property.NameEquals("language"u8)) - { - language = property.Value.GetString(); - continue; - } - if (property.NameEquals("prompt"u8)) + model = new InternalCreateTranscriptionRequestModel(property.Value.GetString()); + continue; + } + if (property.NameEquals("language"u8)) + { + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("prompt"u8)) + { + prompt = property.Value.GetString(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - prompt = property.Value.GetString(); continue; } - if (property.NameEquals("response_format"u8)) + responseFormat = property.Value.GetString().ToAudioTranscriptionFormat(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - responseFormat = property.Value.GetString().ToAudioTranscriptionFormat(); continue; } - if (property.NameEquals("temperature"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("timestamp_granularities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - temperature = property.Value.GetSingle(); continue; } - if (property.NameEquals("timestamp_granularities"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (item.ValueKind == JsonValueKind.Null) { - continue; + array.Add(null); } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(BinaryData.FromString(item.GetRawText())); - } + array.Add(BinaryData.FromString(item.GetRawText())); } - timestampGranularities = array; - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } + timestampGranularities = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AudioTranscriptionOptions( - file, - model, - language, - prompt, - responseFormat, - temperature, - timestampGranularities ?? new ChangeTrackingList(), - serializedAdditionalRawData); - } - - private BinaryData SerializeMultipart(ModelReaderWriterOptions options) - { - using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); - using MemoryStream stream = new MemoryStream(); - content.WriteTo(stream); - if (stream.Position > int.MaxValue) - { - return BinaryData.FromStream(stream); - } - else + if (true) { - return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AudioTranscriptionOptions( + file, + model, + language, + prompt, + responseFormat, + temperature, + timestampGranularities ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } - internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) { - MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); - content.Add(File, "file", "file"); - content.Add(Model.ToString(), "model"); - if (Optional.IsDefined(Language)) - { - content.Add(Language, "language"); - } - if (Optional.IsDefined(Prompt)) - { - content.Add(Prompt, "prompt"); - } - if (Optional.IsDefined(ResponseFormat)) - { - content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); - } - if (Optional.IsDefined(Temperature)) - { - content.Add(Temperature.Value, "temperature"); - } - if (Optional.IsCollectionDefined(TimestampGranularities)) - { - foreach (BinaryData item in TimestampGranularities) - { - content.Add(item, "timestamp_granularities", "timestamp_granularities"); - } - } - return content; + return BinaryData.FromStream(stream); } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + else { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "MFD": - return SerializeMultipart(options); - default: - throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support writing '{options.Format}' format."); - } + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); } + } - AudioTranscriptionOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + { + MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); + content.Add(File, "file", "file"); + content.Add(Model.ToString(), "model"); + if (Optional.IsDefined(Language)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + content.Add(Language, "language"); + } + if (Optional.IsDefined(Prompt)) + { + content.Add(Prompt, "prompt"); + } + if (Optional.IsDefined(ResponseFormat)) + { + content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); + } + if (Optional.IsDefined(Temperature)) + { + content.Add(Temperature.Value, "temperature"); + } + if (Optional.IsCollectionDefined(TimestampGranularities)) + { + foreach (BinaryData item in TimestampGranularities) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAudioTranscriptionOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support reading '{options.Format}' format."); + content.Add(item, "timestamp_granularities", "timestamp_granularities"); } } + return content; + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static AudioTranscriptionOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAudioTranscriptionOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support writing '{options.Format}' format."); } + } + + AudioTranscriptionOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAudioTranscriptionOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AudioTranscriptionOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + internal static AudioTranscriptionOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAudioTranscriptionOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranscriptionOptions.cs b/src/Generated/Models/AudioTranscriptionOptions.cs index 3640e680..9648698c 100644 --- a/src/Generated/Models/AudioTranscriptionOptions.cs +++ b/src/Generated/Models/AudioTranscriptionOptions.cs @@ -5,26 +5,25 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranscriptionOptions { - public partial class AudioTranscriptionOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal AudioTranscriptionOptions(BinaryData file, InternalCreateTranscriptionRequestModel model, string language, string prompt, AudioTranscriptionFormat? responseFormat, float? temperature, IList timestampGranularities, IDictionary serializedAdditionalRawData) - { - File = file; - Model = model; - Language = language; - Prompt = prompt; - ResponseFormat = responseFormat; - Temperature = temperature; - TimestampGranularities = timestampGranularities; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public string Language { get; set; } - public string Prompt { get; set; } - public AudioTranscriptionFormat? ResponseFormat { get; set; } - public float? Temperature { get; set; } + internal AudioTranscriptionOptions(BinaryData file, InternalCreateTranscriptionRequestModel model, string language, string prompt, AudioTranscriptionFormat? responseFormat, float? temperature, IList timestampGranularities, IDictionary serializedAdditionalRawData) + { + File = file; + Model = model; + Language = language; + Prompt = prompt; + ResponseFormat = responseFormat; + Temperature = temperature; + TimestampGranularities = timestampGranularities; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public string Language { get; set; } + public string Prompt { get; set; } + public AudioTranscriptionFormat? ResponseFormat { get; set; } + public float? Temperature { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranslation.Serialization.cs b/src/Generated/Models/AudioTranslation.Serialization.cs index ff7da0c0..739d4ebd 100644 --- a/src/Generated/Models/AudioTranslation.Serialization.cs +++ b/src/Generated/Models/AudioTranslation.Serialization.cs @@ -8,184 +8,183 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranslation : IJsonModel { - public partial class AudioTranslation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranslation)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(AudioTranslation)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("task") != true) - { - writer.WritePropertyName("task"u8); - writer.WriteStringValue(Task.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("language") != true) - { - writer.WritePropertyName("language"u8); - writer.WriteStringValue(Language); - } - if (SerializedAdditionalRawData?.ContainsKey("duration") != true) - { - writer.WritePropertyName("duration"u8); - writer.WriteNumberValue(Convert.ToDouble(Duration.Value.ToString("s\\.FFF"))); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("task") != true) + { + writer.WritePropertyName("task"u8); + writer.WriteStringValue(Task.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("language") != true) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (SerializedAdditionalRawData?.ContainsKey("duration") != true) + { + writer.WritePropertyName("duration"u8); + writer.WriteNumberValue(Convert.ToDouble(Duration.Value.ToString("s\\.FFF"))); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData?.ContainsKey("segments") != true && Optional.IsCollectionDefined(Segments)) + { + writer.WritePropertyName("segments"u8); + writer.WriteStartArray(); + foreach (var item in Segments) { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("segments") != true && Optional.IsCollectionDefined(Segments)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("segments"u8); - writer.WriteStartArray(); - foreach (var item in Segments) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AudioTranslation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AudioTranslation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranslation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAudioTranslation(document.RootElement, options); + throw new FormatException($"The model {nameof(AudioTranslation)} does not support reading '{format}' format."); } - internal static AudioTranslation DeserializeAudioTranslation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAudioTranslation(document.RootElement, options); + } + + internal static AudioTranslation DeserializeAudioTranslation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateTranslationResponseVerboseJsonTask task = default; + string language = default; + TimeSpan? duration = default; + string text = default; + IReadOnlyList segments = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("task"u8)) { - return null; + task = new InternalCreateTranslationResponseVerboseJsonTask(property.Value.GetString()); + continue; } - InternalCreateTranslationResponseVerboseJsonTask task = default; - string language = default; - TimeSpan? duration = default; - string text = default; - IReadOnlyList segments = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("language"u8)) { - if (property.NameEquals("task"u8)) - { - task = new InternalCreateTranslationResponseVerboseJsonTask(property.Value.GetString()); - continue; - } - if (property.NameEquals("language"u8)) - { - language = property.Value.GetString(); - continue; - } - if (property.NameEquals("duration"u8)) - { - duration = TimeSpan.FromSeconds(property.Value.GetDouble()); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("segments"u8)) + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("duration"u8)) + { + duration = TimeSpan.FromSeconds(property.Value.GetDouble()); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("segments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(TranscribedSegment.DeserializeTranscribedSegment(item, options)); - } - segments = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(TranscribedSegment.DeserializeTranscribedSegment(item, options)); } + segments = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AudioTranslation( - task, - language, - duration, - text, - segments ?? new ChangeTrackingList(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AudioTranslation)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AudioTranslation( + task, + language, + duration, + text, + segments ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } - AudioTranslation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAudioTranslation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AudioTranslation)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AudioTranslation)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + AudioTranslation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAudioTranslation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AudioTranslation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranslation.cs b/src/Generated/Models/AudioTranslation.cs index 6dfb907c..719e594a 100644 --- a/src/Generated/Models/AudioTranslation.cs +++ b/src/Generated/Models/AudioTranslation.cs @@ -5,38 +5,37 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranslation { - public partial class AudioTranslation + internal IDictionary SerializedAdditionalRawData { get; set; } + internal AudioTranslation(string language, TimeSpan? duration, string text) + { + Argument.AssertNotNull(language, nameof(language)); + Argument.AssertNotNull(text, nameof(text)); + + Language = language; + Duration = duration; + Text = text; + Segments = new ChangeTrackingList(); + } + + internal AudioTranslation(InternalCreateTranslationResponseVerboseJsonTask task, string language, TimeSpan? duration, string text, IReadOnlyList segments, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal AudioTranslation(string language, TimeSpan? duration, string text) - { - Argument.AssertNotNull(language, nameof(language)); - Argument.AssertNotNull(text, nameof(text)); - - Language = language; - Duration = duration; - Text = text; - Segments = new ChangeTrackingList(); - } - - internal AudioTranslation(InternalCreateTranslationResponseVerboseJsonTask task, string language, TimeSpan? duration, string text, IReadOnlyList segments, IDictionary serializedAdditionalRawData) - { - Task = task; - Language = language; - Duration = duration; - Text = text; - Segments = segments; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal AudioTranslation() - { - } - - public string Language { get; } - public string Text { get; } - public IReadOnlyList Segments { get; } + Task = task; + Language = language; + Duration = duration; + Text = text; + Segments = segments; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal AudioTranslation() + { + } + + public string Language { get; } + public string Text { get; } + public IReadOnlyList Segments { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranslationFormat.Serialization.cs b/src/Generated/Models/AudioTranslationFormat.Serialization.cs index 6c55e965..45aa1945 100644 --- a/src/Generated/Models/AudioTranslationFormat.Serialization.cs +++ b/src/Generated/Models/AudioTranslationFormat.Serialization.cs @@ -4,28 +4,27 @@ using System; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal static partial class AudioTranslationFormatExtensions { - internal static partial class AudioTranslationFormatExtensions + public static string ToSerialString(this AudioTranslationFormat value) => value switch { - public static string ToSerialString(this AudioTranslationFormat value) => value switch - { - AudioTranslationFormat.Simple => "json", - AudioTranslationFormat.Text => "text", - AudioTranslationFormat.Srt => "srt", - AudioTranslationFormat.Verbose => "verbose_json", - AudioTranslationFormat.Vtt => "vtt", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranslationFormat value.") - }; + AudioTranslationFormat.Simple => "json", + AudioTranslationFormat.Text => "text", + AudioTranslationFormat.Srt => "srt", + AudioTranslationFormat.Verbose => "verbose_json", + AudioTranslationFormat.Vtt => "vtt", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranslationFormat value.") + }; - public static AudioTranslationFormat ToAudioTranslationFormat(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "json")) return AudioTranslationFormat.Simple; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "text")) return AudioTranslationFormat.Text; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "srt")) return AudioTranslationFormat.Srt; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "verbose_json")) return AudioTranslationFormat.Verbose; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "vtt")) return AudioTranslationFormat.Vtt; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranslationFormat value."); - } + public static AudioTranslationFormat ToAudioTranslationFormat(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "json")) return AudioTranslationFormat.Simple; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "text")) return AudioTranslationFormat.Text; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "srt")) return AudioTranslationFormat.Srt; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "verbose_json")) return AudioTranslationFormat.Verbose; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "vtt")) return AudioTranslationFormat.Vtt; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AudioTranslationFormat value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranslationOptions.Serialization.cs b/src/Generated/Models/AudioTranslationOptions.Serialization.cs index 5881d9a4..20287a88 100644 --- a/src/Generated/Models/AudioTranslationOptions.Serialization.cs +++ b/src/Generated/Models/AudioTranslationOptions.Serialization.cs @@ -9,228 +9,227 @@ using System.IO; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranslationOptions : IJsonModel { - public partial class AudioTranslationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file") != true) - { - writer.WritePropertyName("file"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file") != true) + { + writer.WritePropertyName("file"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(File); #else - using (JsonDocument document = JsonDocument.Parse(File)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("prompt") != true && Optional.IsDefined(Prompt)) + using (JsonDocument document = JsonDocument.Parse(File)) { - writer.WritePropertyName("prompt"u8); - writer.WriteStringValue(Prompt); + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) - { - writer.WritePropertyName("response_format"u8); - writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); - } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("prompt") != true && Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AudioTranslationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AudioTranslationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAudioTranslationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support reading '{format}' format."); } - internal static AudioTranslationOptions DeserializeAudioTranslationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAudioTranslationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static AudioTranslationOptions DeserializeAudioTranslationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData file = default; + InternalCreateTranslationRequestModel model = default; + string prompt = default; + AudioTranslationFormat? responseFormat = default; + float? temperature = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file"u8)) { - return null; + file = BinaryData.FromString(property.Value.GetRawText()); + continue; } - BinaryData file = default; - InternalCreateTranslationRequestModel model = default; - string prompt = default; - AudioTranslationFormat? responseFormat = default; - float? temperature = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("model"u8)) { - if (property.NameEquals("file"u8)) - { - file = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("model"u8)) - { - model = new InternalCreateTranslationRequestModel(property.Value.GetString()); - continue; - } - if (property.NameEquals("prompt"u8)) - { - prompt = property.Value.GetString(); - continue; - } - if (property.NameEquals("response_format"u8)) + model = new InternalCreateTranslationRequestModel(property.Value.GetString()); + continue; + } + if (property.NameEquals("prompt"u8)) + { + prompt = property.Value.GetString(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - responseFormat = property.Value.GetString().ToAudioTranslationFormat(); continue; } - if (property.NameEquals("temperature"u8)) + responseFormat = property.Value.GetString().ToAudioTranslationFormat(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - temperature = property.Value.GetSingle(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + temperature = property.Value.GetSingle(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new AudioTranslationOptions( - file, - model, - prompt, - responseFormat, - temperature, - serializedAdditionalRawData); - } - - private BinaryData SerializeMultipart(ModelReaderWriterOptions options) - { - using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); - using MemoryStream stream = new MemoryStream(); - content.WriteTo(stream); - if (stream.Position > int.MaxValue) + if (true) { - return BinaryData.FromStream(stream); - } - else - { - return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new AudioTranslationOptions( + file, + model, + prompt, + responseFormat, + temperature, + serializedAdditionalRawData); + } - internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) { - MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); - content.Add(File, "file", "file"); - content.Add(Model.ToString(), "model"); - if (Optional.IsDefined(Prompt)) - { - content.Add(Prompt, "prompt"); - } - if (Optional.IsDefined(ResponseFormat)) - { - content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); - } - if (Optional.IsDefined(Temperature)) - { - content.Add(Temperature.Value, "temperature"); - } - return content; + return BinaryData.FromStream(stream); } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + else { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "MFD": - return SerializeMultipart(options); - default: - throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support writing '{options.Format}' format."); - } + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); } + } - AudioTranslationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + { + MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); + content.Add(File, "file", "file"); + content.Add(Model.ToString(), "model"); + if (Optional.IsDefined(Prompt)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAudioTranslationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support reading '{options.Format}' format."); - } + content.Add(Prompt, "prompt"); } + if (Optional.IsDefined(ResponseFormat)) + { + content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); + } + if (Optional.IsDefined(Temperature)) + { + content.Add(Temperature.Value, "temperature"); + } + return content; + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static AudioTranslationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAudioTranslationOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support writing '{options.Format}' format."); } + } + + AudioTranslationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAudioTranslationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AudioTranslationOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + internal static AudioTranslationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAudioTranslationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/AudioTranslationOptions.cs b/src/Generated/Models/AudioTranslationOptions.cs index a19d2f1f..326f419e 100644 --- a/src/Generated/Models/AudioTranslationOptions.cs +++ b/src/Generated/Models/AudioTranslationOptions.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class AudioTranslationOptions { - public partial class AudioTranslationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal AudioTranslationOptions(BinaryData file, InternalCreateTranslationRequestModel model, string prompt, AudioTranslationFormat? responseFormat, float? temperature, IDictionary serializedAdditionalRawData) - { - File = file; - Model = model; - Prompt = prompt; - ResponseFormat = responseFormat; - Temperature = temperature; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public string Prompt { get; set; } - public AudioTranslationFormat? ResponseFormat { get; set; } - public float? Temperature { get; set; } + internal AudioTranslationOptions(BinaryData file, InternalCreateTranslationRequestModel model, string prompt, AudioTranslationFormat? responseFormat, float? temperature, IDictionary serializedAdditionalRawData) + { + File = file; + Model = model; + Prompt = prompt; + ResponseFormat = responseFormat; + Temperature = temperature; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public string Prompt { get; set; } + public AudioTranslationFormat? ResponseFormat { get; set; } + public float? Temperature { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatCompletion.Serialization.cs b/src/Generated/Models/ChatCompletion.Serialization.cs index 87d34ee8..d4a1562c 100644 --- a/src/Generated/Models/ChatCompletion.Serialization.cs +++ b/src/Generated/Models/ChatCompletion.Serialization.cs @@ -8,238 +8,237 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatCompletion : IJsonModel { - public partial class ChatCompletion : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatCompletion)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatCompletion)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + { + writer.WritePropertyName("choices"u8); + writer.WriteStartArray(); + foreach (var item in Choices) { - writer.WritePropertyName("choices"u8); - writer.WriteStartArray(); - foreach (var item in Choices) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("created") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("created") != true) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("service_tier") != true && Optional.IsDefined(_serviceTier)) + { + if (_serviceTier != null) { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("service_tier"u8); + writer.WriteStringValue(_serviceTier.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + else { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); + writer.WriteNull("service_tier"); } - if (SerializedAdditionalRawData?.ContainsKey("service_tier") != true && Optional.IsDefined(_serviceTier)) + } + if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) + { + writer.WritePropertyName("system_fingerprint"u8); + writer.WriteStringValue(SystemFingerprint); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (_serviceTier != null) - { - writer.WritePropertyName("service_tier"u8); - writer.WriteStringValue(_serviceTier.Value.ToString()); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("service_tier"); + continue; } - } - if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) - { - writer.WritePropertyName("system_fingerprint"u8); - writer.WriteStringValue(SystemFingerprint); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) - { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatCompletion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatCompletion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatCompletion)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatCompletion(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatCompletion)} does not support reading '{format}' format."); } - internal static ChatCompletion DeserializeChatCompletion(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletion(document.RootElement, options); + } + + internal static ChatCompletion DeserializeChatCompletion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IReadOnlyList choices = default; + DateTimeOffset created = default; + string model = default; + InternalCreateChatCompletionResponseServiceTier? serviceTier = default; + string systemFingerprint = default; + InternalCreateChatCompletionResponseObject @object = default; + ChatTokenUsage usage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - IReadOnlyList choices = default; - DateTimeOffset created = default; - string model = default; - InternalCreateChatCompletionResponseServiceTier? serviceTier = default; - string systemFingerprint = default; - InternalCreateChatCompletionResponseObject @object = default; - ChatTokenUsage usage = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("choices"u8)) { - if (property.NameEquals("id"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("choices"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalCreateChatCompletionResponseChoice.DeserializeInternalCreateChatCompletionResponseChoice(item, options)); - } - choices = array; - continue; - } - if (property.NameEquals("created"u8)) - { - created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("service_tier"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - serviceTier = null; - continue; - } - serviceTier = new InternalCreateChatCompletionResponseServiceTier(property.Value.GetString()); - continue; + array.Add(InternalCreateChatCompletionResponseChoice.DeserializeInternalCreateChatCompletionResponseChoice(item, options)); } - if (property.NameEquals("system_fingerprint"u8)) - { - systemFingerprint = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) + choices = array; + continue; + } + if (property.NameEquals("created"u8)) + { + created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("service_tier"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - @object = new InternalCreateChatCompletionResponseObject(property.Value.GetString()); + serviceTier = null; continue; } - if (property.NameEquals("usage"u8)) + serviceTier = new InternalCreateChatCompletionResponseServiceTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("system_fingerprint"u8)) + { + systemFingerprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalCreateChatCompletionResponseObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatCompletion( - id, - choices, - created, - model, - serviceTier, - systemFingerprint, - @object, - usage, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatCompletion)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatCompletion( + id, + choices, + created, + model, + serviceTier, + systemFingerprint, + @object, + usage, + serializedAdditionalRawData); + } - ChatCompletion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatCompletion(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatCompletion)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatCompletion)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatCompletion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatCompletion FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatCompletion(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatCompletion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletion)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatCompletion FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatCompletion(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatCompletion.cs b/src/Generated/Models/ChatCompletion.cs index 74549a43..d73f4c4c 100644 --- a/src/Generated/Models/ChatCompletion.cs +++ b/src/Generated/Models/ChatCompletion.cs @@ -6,44 +6,43 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatCompletion { - public partial class ChatCompletion + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ChatCompletion(string id, IEnumerable choices, DateTimeOffset createdAt, string model) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatCompletion(string id, IEnumerable choices, DateTimeOffset createdAt, string model) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(choices, nameof(choices)); - Argument.AssertNotNull(model, nameof(model)); - - Id = id; - Choices = choices.ToList(); - CreatedAt = createdAt; - Model = model; - } - - internal ChatCompletion(string id, IReadOnlyList choices, DateTimeOffset createdAt, string model, InternalCreateChatCompletionResponseServiceTier? serviceTier, string systemFingerprint, InternalCreateChatCompletionResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) - { - Id = id; - Choices = choices; - CreatedAt = createdAt; - Model = model; - _serviceTier = serviceTier; - SystemFingerprint = systemFingerprint; - Object = @object; - Usage = usage; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal ChatCompletion() - { - } - - public string Id { get; } - public string Model { get; } - public string SystemFingerprint { get; } - - public ChatTokenUsage Usage { get; } + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(choices, nameof(choices)); + Argument.AssertNotNull(model, nameof(model)); + + Id = id; + Choices = choices.ToList(); + CreatedAt = createdAt; + Model = model; } -} + + internal ChatCompletion(string id, IReadOnlyList choices, DateTimeOffset createdAt, string model, InternalCreateChatCompletionResponseServiceTier? serviceTier, string systemFingerprint, InternalCreateChatCompletionResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) + { + Id = id; + Choices = choices; + CreatedAt = createdAt; + Model = model; + _serviceTier = serviceTier; + SystemFingerprint = systemFingerprint; + Object = @object; + Usage = usage; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal ChatCompletion() + { + } + + public string Id { get; } + public string Model { get; } + public string SystemFingerprint { get; } + + public ChatTokenUsage Usage { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatCompletionOptions.Serialization.cs b/src/Generated/Models/ChatCompletionOptions.Serialization.cs index 018cb900..d5043073 100644 --- a/src/Generated/Models/ChatCompletionOptions.Serialization.cs +++ b/src/Generated/Models/ChatCompletionOptions.Serialization.cs @@ -8,623 +8,622 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatCompletionOptions : IJsonModel { - public partial class ChatCompletionOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("messages") != true) + { + writer.WritePropertyName("messages"u8); + SerializeMessagesValue(writer, options); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("frequency_penalty") != true && Optional.IsDefined(FrequencyPenalty)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (FrequencyPenalty != null) { - throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("frequency_penalty"u8); + writer.WriteNumberValue(FrequencyPenalty.Value); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("messages") != true) + else { - writer.WritePropertyName("messages"u8); - SerializeMessagesValue(writer, options); + writer.WriteNull("frequency_penalty"); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("logit_bias") != true && Optional.IsCollectionDefined(LogitBiases)) + { + if (LogitBiases != null) { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.ToString()); + writer.WritePropertyName("logit_bias"u8); + SerializeLogitBiasesValue(writer, options); } - if (SerializedAdditionalRawData?.ContainsKey("frequency_penalty") != true && Optional.IsDefined(FrequencyPenalty)) + else { - if (FrequencyPenalty != null) - { - writer.WritePropertyName("frequency_penalty"u8); - writer.WriteNumberValue(FrequencyPenalty.Value); - } - else - { - writer.WriteNull("frequency_penalty"); - } + writer.WriteNull("logit_bias"); } - if (SerializedAdditionalRawData?.ContainsKey("logit_bias") != true && Optional.IsCollectionDefined(LogitBiases)) + } + if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true && Optional.IsDefined(IncludeLogProbabilities)) + { + if (IncludeLogProbabilities != null) { - if (LogitBiases != null) - { - writer.WritePropertyName("logit_bias"u8); - SerializeLogitBiasesValue(writer, options); - } - else - { - writer.WriteNull("logit_bias"); - } + writer.WritePropertyName("logprobs"u8); + writer.WriteBooleanValue(IncludeLogProbabilities.Value); } - if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true && Optional.IsDefined(IncludeLogProbabilities)) + else { - if (IncludeLogProbabilities != null) - { - writer.WritePropertyName("logprobs"u8); - writer.WriteBooleanValue(IncludeLogProbabilities.Value); - } - else - { - writer.WriteNull("logprobs"); - } + writer.WriteNull("logprobs"); } - if (SerializedAdditionalRawData?.ContainsKey("top_logprobs") != true && Optional.IsDefined(TopLogProbabilityCount)) + } + if (SerializedAdditionalRawData?.ContainsKey("top_logprobs") != true && Optional.IsDefined(TopLogProbabilityCount)) + { + if (TopLogProbabilityCount != null) { - if (TopLogProbabilityCount != null) - { - writer.WritePropertyName("top_logprobs"u8); - writer.WriteNumberValue(TopLogProbabilityCount.Value); - } - else - { - writer.WriteNull("top_logprobs"); - } + writer.WritePropertyName("top_logprobs"u8); + writer.WriteNumberValue(TopLogProbabilityCount.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_tokens") != true && Optional.IsDefined(_deprecatedMaxTokens)) + else { - if (_deprecatedMaxTokens != null) - { - writer.WritePropertyName("max_tokens"u8); - writer.WriteNumberValue(_deprecatedMaxTokens.Value); - } - else - { - writer.WriteNull("max_tokens"); - } + writer.WriteNull("top_logprobs"); } - if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true && Optional.IsDefined(MaxOutputTokenCount)) + } + if (SerializedAdditionalRawData?.ContainsKey("max_tokens") != true && Optional.IsDefined(_deprecatedMaxTokens)) + { + if (_deprecatedMaxTokens != null) { - if (MaxOutputTokenCount != null) - { - writer.WritePropertyName("max_completion_tokens"u8); - writer.WriteNumberValue(MaxOutputTokenCount.Value); - } - else - { - writer.WriteNull("max_completion_tokens"); - } + writer.WritePropertyName("max_tokens"u8); + writer.WriteNumberValue(_deprecatedMaxTokens.Value); } - if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + else { - if (N != null) - { - writer.WritePropertyName("n"u8); - writer.WriteNumberValue(N.Value); - } - else - { - writer.WriteNull("n"); - } + writer.WriteNull("max_tokens"); } - if (SerializedAdditionalRawData?.ContainsKey("presence_penalty") != true && Optional.IsDefined(PresencePenalty)) + } + if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true && Optional.IsDefined(MaxOutputTokenCount)) + { + if (MaxOutputTokenCount != null) { - if (PresencePenalty != null) - { - writer.WritePropertyName("presence_penalty"u8); - writer.WriteNumberValue(PresencePenalty.Value); - } - else - { - writer.WriteNull("presence_penalty"); - } + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxOutputTokenCount.Value); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + else { - writer.WritePropertyName("response_format"u8); - writer.WriteObjectValue(ResponseFormat, options); + writer.WriteNull("max_completion_tokens"); } - if (SerializedAdditionalRawData?.ContainsKey("seed") != true && Optional.IsDefined(Seed)) + } + if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + { + if (N != null) { - if (Seed != null) - { - writer.WritePropertyName("seed"u8); - writer.WriteNumberValue(Seed.Value); - } - else - { - writer.WriteNull("seed"); - } + writer.WritePropertyName("n"u8); + writer.WriteNumberValue(N.Value); } - if (SerializedAdditionalRawData?.ContainsKey("service_tier") != true && Optional.IsDefined(_serviceTier)) + else { - if (_serviceTier != null) - { - writer.WritePropertyName("service_tier"u8); - writer.WriteStringValue(_serviceTier.Value.ToString()); - } - else - { - writer.WriteNull("service_tier"); - } + writer.WriteNull("n"); } - if (SerializedAdditionalRawData?.ContainsKey("stop") != true && Optional.IsCollectionDefined(StopSequences)) + } + if (SerializedAdditionalRawData?.ContainsKey("presence_penalty") != true && Optional.IsDefined(PresencePenalty)) + { + if (PresencePenalty != null) { - if (StopSequences != null) - { - writer.WritePropertyName("stop"u8); - SerializeStopSequencesValue(writer, options); - } - else - { - writer.WriteNull("stop"); - } + writer.WritePropertyName("presence_penalty"u8); + writer.WriteNumberValue(PresencePenalty.Value); } - if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + else { - if (Stream != null) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - else - { - writer.WriteNull("stream"); - } + writer.WriteNull("presence_penalty"); } - if (SerializedAdditionalRawData?.ContainsKey("stream_options") != true && Optional.IsDefined(StreamOptions)) + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteObjectValue(ResponseFormat, options); + } + if (SerializedAdditionalRawData?.ContainsKey("seed") != true && Optional.IsDefined(Seed)) + { + if (Seed != null) { - if (StreamOptions != null) - { - writer.WritePropertyName("stream_options"u8); - writer.WriteObjectValue(StreamOptions, options); - } - else - { - writer.WriteNull("stream_options"); - } + writer.WritePropertyName("seed"u8); + writer.WriteNumberValue(Seed.Value); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + else { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } + writer.WriteNull("seed"); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(TopP)) + } + if (SerializedAdditionalRawData?.ContainsKey("service_tier") != true && Optional.IsDefined(_serviceTier)) + { + if (_serviceTier != null) { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } + writer.WritePropertyName("service_tier"u8); + writer.WriteStringValue(_serviceTier.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + else { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteNull("service_tier"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true && Optional.IsDefined(ToolChoice)) + } + if (SerializedAdditionalRawData?.ContainsKey("stop") != true && Optional.IsCollectionDefined(StopSequences)) + { + if (StopSequences != null) { - writer.WritePropertyName("tool_choice"u8); - writer.WriteObjectValue(ToolChoice, options); + writer.WritePropertyName("stop"u8); + SerializeStopSequencesValue(writer, options); } - if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCallsEnabled)) + else { - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + writer.WriteNull("stop"); } - if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + } + if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + { + if (Stream != null) { - writer.WritePropertyName("user"u8); - writer.WriteStringValue(EndUserId); + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); } - if (SerializedAdditionalRawData?.ContainsKey("function_call") != true && Optional.IsDefined(FunctionChoice)) + else { - writer.WritePropertyName("function_call"u8); - writer.WriteObjectValue(FunctionChoice, options); + writer.WriteNull("stream"); } - if (SerializedAdditionalRawData?.ContainsKey("functions") != true && Optional.IsCollectionDefined(Functions)) + } + if (SerializedAdditionalRawData?.ContainsKey("stream_options") != true && Optional.IsDefined(StreamOptions)) + { + if (StreamOptions != null) { - writer.WritePropertyName("functions"u8); - writer.WriteStartArray(); - foreach (var item in Functions) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("stream_options"u8); + writer.WriteObjectValue(StreamOptions, options); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + writer.WriteNull("stream_options"); } - writer.WriteEndObject(); } - - ChatCompletionOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (Temperature != null) { - throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support reading '{format}' format."); + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatCompletionOptions(document.RootElement, options); } - - internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(TopP)) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList messages = default; - InternalCreateChatCompletionRequestModel model = default; - float? frequencyPenalty = default; - IDictionary logitBias = default; - bool? logprobs = default; - int? topLogprobs = default; - int? maxTokens = default; - int? maxCompletionTokens = default; - int? n = default; - float? presencePenalty = default; - ChatResponseFormat responseFormat = default; - long? seed = default; - InternalCreateChatCompletionRequestServiceTier? serviceTier = default; - IList stop = default; - bool? stream = default; - InternalChatCompletionStreamOptions streamOptions = default; - float? temperature = default; - float? topP = default; - IList tools = default; - ChatToolChoice toolChoice = default; - bool? parallelToolCalls = default; - string user = default; - ChatFunctionChoice functionCall = default; - IList functions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("messages"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatMessage.DeserializeChatMessage(item, options)); - } - messages = array; - continue; - } - if (property.NameEquals("model"u8)) + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true && Optional.IsDefined(ToolChoice)) + { + writer.WritePropertyName("tool_choice"u8); + writer.WriteObjectValue(ToolChoice, options); + } + if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCallsEnabled)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(EndUserId); + } + if (SerializedAdditionalRawData?.ContainsKey("function_call") != true && Optional.IsDefined(FunctionChoice)) + { + writer.WritePropertyName("function_call"u8); + writer.WriteObjectValue(FunctionChoice, options); + } + if (SerializedAdditionalRawData?.ContainsKey("functions") != true && Optional.IsCollectionDefined(Functions)) + { + writer.WritePropertyName("functions"u8); + writer.WriteStartArray(); + foreach (var item in Functions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - model = new InternalCreateChatCompletionRequestModel(property.Value.GetString()); continue; } - if (property.NameEquals("frequency_penalty"u8)) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - frequencyPenalty = null; - continue; - } - frequencyPenalty = property.Value.GetSingle(); - continue; + JsonSerializer.Serialize(writer, document.RootElement); } - if (property.NameEquals("logit_bias"u8)) +#endif + } + } + writer.WriteEndObject(); + } + + ChatCompletionOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletionOptions(document.RootElement, options); + } + + internal static ChatCompletionOptions DeserializeChatCompletionOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList messages = default; + InternalCreateChatCompletionRequestModel model = default; + float? frequencyPenalty = default; + IDictionary logitBias = default; + bool? logprobs = default; + int? topLogprobs = default; + int? maxTokens = default; + int? maxCompletionTokens = default; + int? n = default; + float? presencePenalty = default; + ChatResponseFormat responseFormat = default; + long? seed = default; + InternalCreateChatCompletionRequestServiceTier? serviceTier = default; + IList stop = default; + bool? stream = default; + InternalChatCompletionStreamOptions streamOptions = default; + float? temperature = default; + float? topP = default; + IList tools = default; + ChatToolChoice toolChoice = default; + bool? parallelToolCalls = default; + string user = default; + ChatFunctionChoice functionCall = default; + IList functions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - DeserializeLogitBiasesValue(property, ref logitBias); - continue; + array.Add(ChatMessage.DeserializeChatMessage(item, options)); } - if (property.NameEquals("logprobs"u8)) + messages = array; + continue; + } + if (property.NameEquals("model"u8)) + { + model = new InternalCreateChatCompletionRequestModel(property.Value.GetString()); + continue; + } + if (property.NameEquals("frequency_penalty"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - logprobs = null; - continue; - } - logprobs = property.Value.GetBoolean(); + frequencyPenalty = null; continue; } - if (property.NameEquals("top_logprobs"u8)) + frequencyPenalty = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("logit_bias"u8)) + { + DeserializeLogitBiasesValue(property, ref logitBias); + continue; + } + if (property.NameEquals("logprobs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topLogprobs = null; - continue; - } - topLogprobs = property.Value.GetInt32(); + logprobs = null; continue; } - if (property.NameEquals("max_tokens"u8)) + logprobs = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("top_logprobs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxTokens = null; - continue; - } - maxTokens = property.Value.GetInt32(); + topLogprobs = null; continue; } - if (property.NameEquals("max_completion_tokens"u8)) + topLogprobs = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxCompletionTokens = null; - continue; - } - maxCompletionTokens = property.Value.GetInt32(); + maxTokens = null; continue; } - if (property.NameEquals("n"u8)) + maxTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - n = null; - continue; - } - n = property.Value.GetInt32(); + maxCompletionTokens = null; continue; } - if (property.NameEquals("presence_penalty"u8)) + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("n"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - presencePenalty = null; - continue; - } - presencePenalty = property.Value.GetSingle(); + n = null; continue; } - if (property.NameEquals("response_format"u8)) + n = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("presence_penalty"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - responseFormat = ChatResponseFormat.DeserializeChatResponseFormat(property.Value, options); + presencePenalty = null; continue; } - if (property.NameEquals("seed"u8)) + presencePenalty = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - seed = null; - continue; - } - seed = property.Value.GetInt64(); continue; } - if (property.NameEquals("service_tier"u8)) + responseFormat = ChatResponseFormat.DeserializeChatResponseFormat(property.Value, options); + continue; + } + if (property.NameEquals("seed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - serviceTier = null; - continue; - } - serviceTier = new InternalCreateChatCompletionRequestServiceTier(property.Value.GetString()); + seed = null; continue; } - if (property.NameEquals("stop"u8)) + seed = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("service_tier"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - DeserializeStopSequencesValue(property, ref stop); + serviceTier = null; continue; } - if (property.NameEquals("stream"u8)) + serviceTier = new InternalCreateChatCompletionRequestServiceTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("stop"u8)) + { + DeserializeStopSequencesValue(property, ref stop); + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - stream = null; - continue; - } - stream = property.Value.GetBoolean(); + stream = null; continue; } - if (property.NameEquals("stream_options"u8)) + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("stream_options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - streamOptions = null; - continue; - } - streamOptions = InternalChatCompletionStreamOptions.DeserializeInternalChatCompletionStreamOptions(property.Value, options); + streamOptions = null; continue; } - if (property.NameEquals("temperature"u8)) + streamOptions = InternalChatCompletionStreamOptions.DeserializeInternalChatCompletionStreamOptions(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); + temperature = null; continue; } - if (property.NameEquals("top_p"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); + topP = null; continue; } - if (property.NameEquals("tools"u8)) + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatTool.DeserializeChatTool(item, options)); - } - tools = array; continue; } - if (property.NameEquals("tool_choice"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - toolChoice = ChatToolChoice.DeserializeChatToolChoice(property.Value, options); - continue; + array.Add(ChatTool.DeserializeChatTool(item, options)); } - if (property.NameEquals("parallel_tool_calls"u8)) + tools = array; + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parallelToolCalls = property.Value.GetBoolean(); continue; } - if (property.NameEquals("user"u8)) + toolChoice = ChatToolChoice.DeserializeChatToolChoice(property.Value, options); + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - user = property.Value.GetString(); continue; } - if (property.NameEquals("function_call"u8)) + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("user"u8)) + { + user = property.Value.GetString(); + continue; + } + if (property.NameEquals("function_call"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - functionCall = ChatFunctionChoice.DeserializeChatFunctionChoice(property.Value, options); continue; } - if (property.NameEquals("functions"u8)) + functionCall = ChatFunctionChoice.DeserializeChatFunctionChoice(property.Value, options); + continue; + } + if (property.NameEquals("functions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatFunction.DeserializeChatFunction(item, options)); - } - functions = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(ChatFunction.DeserializeChatFunction(item, options)); } + functions = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatCompletionOptions( - messages, - model, - frequencyPenalty, - logitBias ?? new ChangeTrackingDictionary(), - logprobs, - topLogprobs, - maxTokens, - maxCompletionTokens, - n, - presencePenalty, - responseFormat, - seed, - serviceTier, - stop ?? new ChangeTrackingList(), - stream, - streamOptions, - temperature, - topP, - tools ?? new ChangeTrackingList(), - toolChoice, - parallelToolCalls, - user, - functionCall, - functions ?? new ChangeTrackingList(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatCompletionOptions( + messages, + model, + frequencyPenalty, + logitBias ?? new ChangeTrackingDictionary(), + logprobs, + topLogprobs, + maxTokens, + maxCompletionTokens, + n, + presencePenalty, + responseFormat, + seed, + serviceTier, + stop ?? new ChangeTrackingList(), + stream, + streamOptions, + temperature, + topP, + tools ?? new ChangeTrackingList(), + toolChoice, + parallelToolCalls, + user, + functionCall, + functions ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } - ChatCompletionOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatCompletionOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatCompletionOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatCompletionOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatCompletionOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatCompletionOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletionOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatCompletionOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatCompletionOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatCompletionOptions.cs b/src/Generated/Models/ChatCompletionOptions.cs index 4e3e063b..35e5a0ff 100644 --- a/src/Generated/Models/ChatCompletionOptions.cs +++ b/src/Generated/Models/ChatCompletionOptions.cs @@ -6,45 +6,44 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatCompletionOptions { - public partial class ChatCompletionOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatCompletionOptions(IList messages, InternalCreateChatCompletionRequestModel model, float? frequencyPenalty, IDictionary logitBiases, bool? includeLogProbabilities, int? topLogProbabilityCount, int? deprecatedMaxTokens, int? maxOutputTokenCount, int? n, float? presencePenalty, ChatResponseFormat responseFormat, long? seed, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList stopSequences, bool? stream, InternalChatCompletionStreamOptions streamOptions, float? temperature, float? topP, IList tools, ChatToolChoice toolChoice, bool? parallelToolCallsEnabled, string endUserId, ChatFunctionChoice functionChoice, IList functions, IDictionary serializedAdditionalRawData) - { - Messages = messages; - Model = model; - FrequencyPenalty = frequencyPenalty; - LogitBiases = logitBiases; - IncludeLogProbabilities = includeLogProbabilities; - TopLogProbabilityCount = topLogProbabilityCount; - _deprecatedMaxTokens = deprecatedMaxTokens; - MaxOutputTokenCount = maxOutputTokenCount; - N = n; - PresencePenalty = presencePenalty; - ResponseFormat = responseFormat; - Seed = seed; - _serviceTier = serviceTier; - StopSequences = stopSequences; - Stream = stream; - StreamOptions = streamOptions; - Temperature = temperature; - TopP = topP; - Tools = tools; - ToolChoice = toolChoice; - ParallelToolCallsEnabled = parallelToolCallsEnabled; - EndUserId = endUserId; - FunctionChoice = functionChoice; - Functions = functions; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public float? FrequencyPenalty { get; set; } - public float? PresencePenalty { get; set; } - public ChatResponseFormat ResponseFormat { get; set; } - public float? Temperature { get; set; } - public float? TopP { get; set; } - public IList Tools { get; } + internal ChatCompletionOptions(IList messages, InternalCreateChatCompletionRequestModel model, float? frequencyPenalty, IDictionary logitBiases, bool? includeLogProbabilities, int? topLogProbabilityCount, int? deprecatedMaxTokens, int? maxOutputTokenCount, int? n, float? presencePenalty, ChatResponseFormat responseFormat, long? seed, InternalCreateChatCompletionRequestServiceTier? serviceTier, IList stopSequences, bool? stream, InternalChatCompletionStreamOptions streamOptions, float? temperature, float? topP, IList tools, ChatToolChoice toolChoice, bool? parallelToolCallsEnabled, string endUserId, ChatFunctionChoice functionChoice, IList functions, IDictionary serializedAdditionalRawData) + { + Messages = messages; + Model = model; + FrequencyPenalty = frequencyPenalty; + LogitBiases = logitBiases; + IncludeLogProbabilities = includeLogProbabilities; + TopLogProbabilityCount = topLogProbabilityCount; + _deprecatedMaxTokens = deprecatedMaxTokens; + MaxOutputTokenCount = maxOutputTokenCount; + N = n; + PresencePenalty = presencePenalty; + ResponseFormat = responseFormat; + Seed = seed; + _serviceTier = serviceTier; + StopSequences = stopSequences; + Stream = stream; + StreamOptions = streamOptions; + Temperature = temperature; + TopP = topP; + Tools = tools; + ToolChoice = toolChoice; + ParallelToolCallsEnabled = parallelToolCallsEnabled; + EndUserId = endUserId; + FunctionChoice = functionChoice; + Functions = functions; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public float? FrequencyPenalty { get; set; } + public float? PresencePenalty { get; set; } + public ChatResponseFormat ResponseFormat { get; set; } + public float? Temperature { get; set; } + public float? TopP { get; set; } + public IList Tools { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatFinishReason.Serialization.cs b/src/Generated/Models/ChatFinishReason.Serialization.cs index 3bfd7746..5a12659a 100644 --- a/src/Generated/Models/ChatFinishReason.Serialization.cs +++ b/src/Generated/Models/ChatFinishReason.Serialization.cs @@ -4,28 +4,27 @@ using System; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal static partial class ChatFinishReasonExtensions { - internal static partial class ChatFinishReasonExtensions + public static string ToSerialString(this ChatFinishReason value) => value switch { - public static string ToSerialString(this ChatFinishReason value) => value switch - { - ChatFinishReason.Stop => "stop", - ChatFinishReason.Length => "length", - ChatFinishReason.ToolCalls => "tool_calls", - ChatFinishReason.ContentFilter => "content_filter", - ChatFinishReason.FunctionCall => "function_call", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatFinishReason value.") - }; + ChatFinishReason.Stop => "stop", + ChatFinishReason.Length => "length", + ChatFinishReason.ToolCalls => "tool_calls", + ChatFinishReason.ContentFilter => "content_filter", + ChatFinishReason.FunctionCall => "function_call", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatFinishReason value.") + }; - public static ChatFinishReason ToChatFinishReason(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "stop")) return ChatFinishReason.Stop; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "length")) return ChatFinishReason.Length; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "tool_calls")) return ChatFinishReason.ToolCalls; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "content_filter")) return ChatFinishReason.ContentFilter; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "function_call")) return ChatFinishReason.FunctionCall; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatFinishReason value."); - } + public static ChatFinishReason ToChatFinishReason(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "stop")) return ChatFinishReason.Stop; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "length")) return ChatFinishReason.Length; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "tool_calls")) return ChatFinishReason.ToolCalls; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "content_filter")) return ChatFinishReason.ContentFilter; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "function_call")) return ChatFinishReason.FunctionCall; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatFinishReason value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatFunction.Serialization.cs b/src/Generated/Models/ChatFunction.Serialization.cs index 8974ea69..d92637e3 100644 --- a/src/Generated/Models/ChatFunction.Serialization.cs +++ b/src/Generated/Models/ChatFunction.Serialization.cs @@ -8,159 +8,158 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatFunction : IJsonModel { - public partial class ChatFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatFunction)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatFunction)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(FunctionDescription)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(FunctionDescription); - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(FunctionName); - } - if (SerializedAdditionalRawData?.ContainsKey("parameters") != true && Optional.IsDefined(FunctionParameters)) - { - writer.WritePropertyName("parameters"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(FunctionDescription)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(FunctionDescription); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(FunctionName); + } + if (SerializedAdditionalRawData?.ContainsKey("parameters") != true && Optional.IsDefined(FunctionParameters)) + { + writer.WritePropertyName("parameters"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(FunctionParameters); #else - using (JsonDocument document = JsonDocument.Parse(FunctionParameters)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(FunctionParameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatFunction(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatFunction)} does not support reading '{format}' format."); } - internal static ChatFunction DeserializeChatFunction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatFunction(document.RootElement, options); + } + + internal static ChatFunction DeserializeChatFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + BinaryData parameters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) { - return null; + description = property.Value.GetString(); + continue; } - string description = default; - string name = default; - BinaryData parameters = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("description"u8)) - { - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("parameters"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("parameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parameters = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + parameters = BinaryData.FromString(property.Value.GetRawText()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatFunction(description, name, parameters, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatFunction)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatFunction(description, name, parameters, serializedAdditionalRawData); + } - ChatFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatFunction)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatFunction)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatFunction(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatFunction)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatFunction.cs b/src/Generated/Models/ChatFunction.cs index e3abf7d8..2a2ef7ff 100644 --- a/src/Generated/Models/ChatFunction.cs +++ b/src/Generated/Models/ChatFunction.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatFunction { - public partial class ChatFunction - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatFunction(string functionDescription, string functionName, BinaryData functionParameters, IDictionary serializedAdditionalRawData) - { - FunctionDescription = functionDescription; - FunctionName = functionName; - FunctionParameters = functionParameters; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ChatFunction(string functionDescription, string functionName, BinaryData functionParameters, IDictionary serializedAdditionalRawData) + { + FunctionDescription = functionDescription; + FunctionName = functionName; + FunctionParameters = functionParameters; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ChatFunction() - { - } + internal ChatFunction() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatFunctionCall.Serialization.cs b/src/Generated/Models/ChatFunctionCall.Serialization.cs index f5f498a8..f3c22d8b 100644 --- a/src/Generated/Models/ChatFunctionCall.Serialization.cs +++ b/src/Generated/Models/ChatFunctionCall.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatFunctionCall : IJsonModel { - public partial class ChatFunctionCall : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(FunctionArguments); - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(FunctionName); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(FunctionArguments); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(FunctionName); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatFunctionCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatFunctionCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatFunctionCall(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support reading '{format}' format."); } - internal static ChatFunctionCall DeserializeChatFunctionCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatFunctionCall(document.RootElement, options); + } + + internal static ChatFunctionCall DeserializeChatFunctionCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string arguments = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("arguments"u8)) { - return null; + arguments = property.Value.GetString(); + continue; } - string arguments = default; - string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + name = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatFunctionCall(arguments, name, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatFunctionCall(arguments, name, serializedAdditionalRawData); + } - ChatFunctionCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatFunctionCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatFunctionCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatFunctionCall FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatFunctionCall(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatFunctionCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatFunctionCall)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatFunctionCall FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatFunctionCall(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatFunctionCall.cs b/src/Generated/Models/ChatFunctionCall.cs index d10f638a..8cb8db5f 100644 --- a/src/Generated/Models/ChatFunctionCall.cs +++ b/src/Generated/Models/ChatFunctionCall.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatFunctionCall { - public partial class ChatFunctionCall - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatFunctionCall(string functionArguments, string functionName, IDictionary serializedAdditionalRawData) - { - FunctionArguments = functionArguments; - FunctionName = functionName; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ChatFunctionCall(string functionArguments, string functionName, IDictionary serializedAdditionalRawData) + { + FunctionArguments = functionArguments; + FunctionName = functionName; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ChatFunctionCall() - { - } + internal ChatFunctionCall() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatFunctionChoice.Serialization.cs b/src/Generated/Models/ChatFunctionChoice.Serialization.cs index eb482e95..4197a11b 100644 --- a/src/Generated/Models/ChatFunctionChoice.Serialization.cs +++ b/src/Generated/Models/ChatFunctionChoice.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatFunctionChoice : IJsonModel { - public partial class ChatFunctionChoice : IJsonModel + ChatFunctionChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ChatFunctionChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatFunctionChoice)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatFunctionChoice(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatFunctionChoice)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatFunctionChoice(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatFunctionChoice)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - ChatFunctionChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatFunctionChoice(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatFunctionChoice)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatFunctionChoice)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatFunctionChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatFunctionChoice FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatFunctionChoice(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatFunctionChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatFunctionChoice)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatFunctionChoice FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatFunctionChoice(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatFunctionChoice.cs b/src/Generated/Models/ChatFunctionChoice.cs index a103d4f4..1b36ac7d 100644 --- a/src/Generated/Models/ChatFunctionChoice.cs +++ b/src/Generated/Models/ChatFunctionChoice.cs @@ -5,10 +5,9 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatFunctionChoice { - public partial class ChatFunctionChoice - { - internal IDictionary SerializedAdditionalRawData { get; set; } - } -} + internal IDictionary SerializedAdditionalRawData { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatImageDetailLevel.cs b/src/Generated/Models/ChatImageDetailLevel.cs index 28d44ae5..3b6629c2 100644 --- a/src/Generated/Models/ChatImageDetailLevel.cs +++ b/src/Generated/Models/ChatImageDetailLevel.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public readonly partial struct ChatImageDetailLevel : IEquatable { - public readonly partial struct ChatImageDetailLevel : IEquatable + private readonly string _value; + + public ChatImageDetailLevel(string value) { - private readonly string _value; - - public ChatImageDetailLevel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string LowValue = "low"; - private const string HighValue = "high"; - - public static ChatImageDetailLevel Auto { get; } = new ChatImageDetailLevel(AutoValue); - public static ChatImageDetailLevel Low { get; } = new ChatImageDetailLevel(LowValue); - public static ChatImageDetailLevel High { get; } = new ChatImageDetailLevel(HighValue); - public static bool operator ==(ChatImageDetailLevel left, ChatImageDetailLevel right) => left.Equals(right); - public static bool operator !=(ChatImageDetailLevel left, ChatImageDetailLevel right) => !left.Equals(right); - public static implicit operator ChatImageDetailLevel(string value) => new ChatImageDetailLevel(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ChatImageDetailLevel other && Equals(other); - public bool Equals(ChatImageDetailLevel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AutoValue = "auto"; + private const string LowValue = "low"; + private const string HighValue = "high"; + + public static ChatImageDetailLevel Auto { get; } = new ChatImageDetailLevel(AutoValue); + public static ChatImageDetailLevel Low { get; } = new ChatImageDetailLevel(LowValue); + public static ChatImageDetailLevel High { get; } = new ChatImageDetailLevel(HighValue); + public static bool operator ==(ChatImageDetailLevel left, ChatImageDetailLevel right) => left.Equals(right); + public static bool operator !=(ChatImageDetailLevel left, ChatImageDetailLevel right) => !left.Equals(right); + public static implicit operator ChatImageDetailLevel(string value) => new ChatImageDetailLevel(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatImageDetailLevel other && Equals(other); + public bool Equals(ChatImageDetailLevel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/ChatMessage.Serialization.cs b/src/Generated/Models/ChatMessage.Serialization.cs index 971105a9..61b6e6f8 100644 --- a/src/Generated/Models/ChatMessage.Serialization.cs +++ b/src/Generated/Models/ChatMessage.Serialization.cs @@ -8,86 +8,85 @@ using System.Text.Json; using OpenAI.FineTuning; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +[PersistableModelProxy(typeof(InternalUnknownChatMessage))] +public partial class ChatMessage : IJsonModel { - [PersistableModelProxy(typeof(InternalUnknownChatMessage))] - public partial class ChatMessage : IJsonModel + ChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{format}' format."); } - internal static ChatMessage DeserializeChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("role", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case null: return InternalFineTuneChatCompletionRequestAssistantMessage.DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(element, options); - case "assistant": return AssistantChatMessage.DeserializeAssistantChatMessage(element, options); - case "function": return FunctionChatMessage.DeserializeFunctionChatMessage(element, options); - case "system": return SystemChatMessage.DeserializeSystemChatMessage(element, options); - case "tool": return ToolChatMessage.DeserializeToolChatMessage(element, options); - case "user": return UserChatMessage.DeserializeUserChatMessage(element, options); - } - } - return InternalUnknownChatMessage.DeserializeInternalUnknownChatMessage(element, options); - } + internal static ChatMessage DeserializeChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatMessage)} does not support writing '{options.Format}' format."); - } + return null; } - - ChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("role", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{options.Format}' format."); + case null: return InternalFineTuneChatCompletionRequestAssistantMessage.DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(element, options); + case "assistant": return AssistantChatMessage.DeserializeAssistantChatMessage(element, options); + case "function": return FunctionChatMessage.DeserializeFunctionChatMessage(element, options); + case "system": return SystemChatMessage.DeserializeSystemChatMessage(element, options); + case "tool": return ToolChatMessage.DeserializeToolChatMessage(element, options); + case "user": return UserChatMessage.DeserializeUserChatMessage(element, options); } } + return InternalUnknownChatMessage.DeserializeInternalUnknownChatMessage(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatMessage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatMessage)} does not support writing '{options.Format}' format."); } + } + + ChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatMessage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatMessage.cs b/src/Generated/Models/ChatMessage.cs index 06a9f1ad..a86f81a5 100644 --- a/src/Generated/Models/ChatMessage.cs +++ b/src/Generated/Models/ChatMessage.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public abstract partial class ChatMessage { - public abstract partial class ChatMessage - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData) - { - Role = role; - Content = content; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatMessageContentPart.Serialization.cs b/src/Generated/Models/ChatMessageContentPart.Serialization.cs index aa068ae4..ebcf4892 100644 --- a/src/Generated/Models/ChatMessageContentPart.Serialization.cs +++ b/src/Generated/Models/ChatMessageContentPart.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatMessageContentPart : IJsonModel { - public partial class ChatMessageContentPart : IJsonModel + ChatMessageContentPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ChatMessageContentPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatMessageContentPart)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatMessageContentPart(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatMessageContentPart)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessageContentPart(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatMessageContentPart)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - ChatMessageContentPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatMessageContentPart(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatMessageContentPart)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatMessageContentPart)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatMessageContentPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatMessageContentPart FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatMessageContentPart(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatMessageContentPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessageContentPart)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatMessageContentPart FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatMessageContentPart(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatMessageContentPart.cs b/src/Generated/Models/ChatMessageContentPart.cs index ac4ef86e..44c7848a 100644 --- a/src/Generated/Models/ChatMessageContentPart.cs +++ b/src/Generated/Models/ChatMessageContentPart.cs @@ -5,10 +5,9 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatMessageContentPart { - public partial class ChatMessageContentPart - { - internal IDictionary SerializedAdditionalRawData { get; set; } - } -} + internal IDictionary SerializedAdditionalRawData { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatMessageRole.Serialization.cs b/src/Generated/Models/ChatMessageRole.Serialization.cs index 4380b11e..4ecc93c7 100644 --- a/src/Generated/Models/ChatMessageRole.Serialization.cs +++ b/src/Generated/Models/ChatMessageRole.Serialization.cs @@ -4,28 +4,27 @@ using System; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal static partial class ChatMessageRoleExtensions { - internal static partial class ChatMessageRoleExtensions + public static string ToSerialString(this ChatMessageRole value) => value switch { - public static string ToSerialString(this ChatMessageRole value) => value switch - { - ChatMessageRole.System => "system", - ChatMessageRole.User => "user", - ChatMessageRole.Assistant => "assistant", - ChatMessageRole.Tool => "tool", - ChatMessageRole.Function => "function", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageRole value.") - }; + ChatMessageRole.System => "system", + ChatMessageRole.User => "user", + ChatMessageRole.Assistant => "assistant", + ChatMessageRole.Tool => "tool", + ChatMessageRole.Function => "function", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageRole value.") + }; - public static ChatMessageRole ToChatMessageRole(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "system")) return ChatMessageRole.System; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "user")) return ChatMessageRole.User; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "assistant")) return ChatMessageRole.Assistant; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "tool")) return ChatMessageRole.Tool; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "function")) return ChatMessageRole.Function; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageRole value."); - } + public static ChatMessageRole ToChatMessageRole(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "system")) return ChatMessageRole.System; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "user")) return ChatMessageRole.User; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "assistant")) return ChatMessageRole.Assistant; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "tool")) return ChatMessageRole.Tool; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "function")) return ChatMessageRole.Function; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ChatMessageRole value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs b/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs index 3ef3edc7..63d2dd77 100644 --- a/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs +++ b/src/Generated/Models/ChatOutputTokenUsageDetails.Serialization.cs @@ -8,130 +8,129 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatOutputTokenUsageDetails : IJsonModel { - public partial class ChatOutputTokenUsageDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("reasoning_tokens") != true) - { - writer.WritePropertyName("reasoning_tokens"u8); - writer.WriteNumberValue(ReasoningTokenCount); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("reasoning_tokens") != true) + { + writer.WritePropertyName("reasoning_tokens"u8); + writer.WriteNumberValue(ReasoningTokenCount); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatOutputTokenUsageDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatOutputTokenUsageDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatOutputTokenUsageDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support reading '{format}' format."); } - internal static ChatOutputTokenUsageDetails DeserializeChatOutputTokenUsageDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatOutputTokenUsageDetails(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int reasoningTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static ChatOutputTokenUsageDetails DeserializeChatOutputTokenUsageDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int reasoningTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reasoning_tokens"u8)) { - if (property.NameEquals("reasoning_tokens"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - reasoningTokens = property.Value.GetInt32(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + reasoningTokens = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatOutputTokenUsageDetails(reasoningTokens, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatOutputTokenUsageDetails(reasoningTokens, serializedAdditionalRawData); + } - ChatOutputTokenUsageDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatOutputTokenUsageDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatOutputTokenUsageDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatOutputTokenUsageDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatOutputTokenUsageDetails(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatOutputTokenUsageDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatOutputTokenUsageDetails)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatOutputTokenUsageDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatOutputTokenUsageDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatOutputTokenUsageDetails.cs b/src/Generated/Models/ChatOutputTokenUsageDetails.cs index 88bc8370..18860e21 100644 --- a/src/Generated/Models/ChatOutputTokenUsageDetails.cs +++ b/src/Generated/Models/ChatOutputTokenUsageDetails.cs @@ -5,19 +5,18 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatOutputTokenUsageDetails { - public partial class ChatOutputTokenUsageDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ChatOutputTokenUsageDetails() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatOutputTokenUsageDetails() - { - } + } - internal ChatOutputTokenUsageDetails(int reasoningTokenCount, IDictionary serializedAdditionalRawData) - { - ReasoningTokenCount = reasoningTokenCount; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ChatOutputTokenUsageDetails(int reasoningTokenCount, IDictionary serializedAdditionalRawData) + { + ReasoningTokenCount = reasoningTokenCount; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatResponseFormat.Serialization.cs b/src/Generated/Models/ChatResponseFormat.Serialization.cs index 26c29785..9639202e 100644 --- a/src/Generated/Models/ChatResponseFormat.Serialization.cs +++ b/src/Generated/Models/ChatResponseFormat.Serialization.cs @@ -7,83 +7,82 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +[PersistableModelProxy(typeof(InternalUnknownChatResponseFormat))] +public partial class ChatResponseFormat : IJsonModel { - [PersistableModelProxy(typeof(InternalUnknownChatResponseFormat))] - public partial class ChatResponseFormat : IJsonModel + ChatResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ChatResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatResponseFormat(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{format}' format."); } - internal static ChatResponseFormat DeserializeChatResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatResponseFormat(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "json_object": return InternalChatResponseFormatJsonObject.DeserializeInternalChatResponseFormatJsonObject(element, options); - case "json_schema": return InternalChatResponseFormatJsonSchema.DeserializeInternalChatResponseFormatJsonSchema(element, options); - case "text": return InternalChatResponseFormatText.DeserializeInternalChatResponseFormatText(element, options); - } - } - return InternalUnknownChatResponseFormat.DeserializeInternalUnknownChatResponseFormat(element, options); - } + internal static ChatResponseFormat DeserializeChatResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support writing '{options.Format}' format."); - } + return null; } - - ChatResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatResponseFormat(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{options.Format}' format."); + case "json_object": return InternalChatResponseFormatJsonObject.DeserializeInternalChatResponseFormatJsonObject(element, options); + case "json_schema": return InternalChatResponseFormatJsonSchema.DeserializeInternalChatResponseFormatJsonSchema(element, options); + case "text": return InternalChatResponseFormatText.DeserializeInternalChatResponseFormatText(element, options); } } + return InternalUnknownChatResponseFormat.DeserializeInternalUnknownChatResponseFormat(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatResponseFormat FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatResponseFormat(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support writing '{options.Format}' format."); } + } + + ChatResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatResponseFormat FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatResponseFormat(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatResponseFormat.cs b/src/Generated/Models/ChatResponseFormat.cs index 54eb0a8b..89a8d785 100644 --- a/src/Generated/Models/ChatResponseFormat.cs +++ b/src/Generated/Models/ChatResponseFormat.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public abstract partial class ChatResponseFormat { - public abstract partial class ChatResponseFormat + internal IDictionary SerializedAdditionalRawData { get; set; } + protected ChatResponseFormat() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected ChatResponseFormat() - { - } - - internal ChatResponseFormat(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal ChatResponseFormat(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTokenLogProbabilityDetails.Serialization.cs b/src/Generated/Models/ChatTokenLogProbabilityDetails.Serialization.cs index eea644f3..4ee4f881 100644 --- a/src/Generated/Models/ChatTokenLogProbabilityDetails.Serialization.cs +++ b/src/Generated/Models/ChatTokenLogProbabilityDetails.Serialization.cs @@ -8,192 +8,191 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTokenLogProbabilityDetails : IJsonModel { - public partial class ChatTokenLogProbabilityDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("token") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("token") != true) + { + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + } + if (SerializedAdditionalRawData?.ContainsKey("logprob") != true) + { + writer.WritePropertyName("logprob"u8); + writer.WriteNumberValue(LogProbability); + } + if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + { + if (Utf8Bytes != null) { - writer.WritePropertyName("token"u8); - writer.WriteStringValue(Token); + writer.WritePropertyName("bytes"u8); + writer.WriteStartArray(); + foreach (var item in Utf8Bytes.Value.Span) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("logprob") != true) + else { - writer.WritePropertyName("logprob"u8); - writer.WriteNumberValue(LogProbability); + writer.WriteNull("bytes"); } - if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("top_logprobs") != true) + { + writer.WritePropertyName("top_logprobs"u8); + writer.WriteStartArray(); + foreach (var item in TopLogProbabilities) { - if (Utf8Bytes != null) - { - writer.WritePropertyName("bytes"u8); - writer.WriteStartArray(); - foreach (var item in Utf8Bytes.Value.Span) - { - writer.WriteNumberValue(item); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("bytes"); - } + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("top_logprobs") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("top_logprobs"u8); - writer.WriteStartArray(); - foreach (var item in TopLogProbabilities) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatTokenLogProbabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatTokenLogProbabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatTokenLogProbabilityDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support reading '{format}' format."); } - internal static ChatTokenLogProbabilityDetails DeserializeChatTokenLogProbabilityDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatTokenLogProbabilityDetails(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static ChatTokenLogProbabilityDetails DeserializeChatTokenLogProbabilityDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string token = default; + float logprob = default; + ReadOnlyMemory? bytes = default; + IReadOnlyList topLogprobs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("token"u8)) { - return null; + token = property.Value.GetString(); + continue; } - string token = default; - float logprob = default; - ReadOnlyMemory? bytes = default; - IReadOnlyList topLogprobs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("logprob"u8)) { - if (property.NameEquals("token"u8)) - { - token = property.Value.GetString(); - continue; - } - if (property.NameEquals("logprob"u8)) - { - logprob = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("bytes"u8)) + logprob = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("bytes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - int index = 0; - byte[] array = new byte[property.Value.GetArrayLength()]; - foreach (var item in property.Value.EnumerateArray()) - { - array[index] = item.GetByte(); - index++; - } - bytes = new ReadOnlyMemory?(array); continue; } - if (property.NameEquals("top_logprobs"u8)) + int index = 0; + byte[] array = new byte[property.Value.GetArrayLength()]; + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatTokenTopLogProbabilityDetails.DeserializeChatTokenTopLogProbabilityDetails(item, options)); - } - topLogprobs = array; - continue; + array[index] = item.GetByte(); + index++; } - if (true) + bytes = new ReadOnlyMemory?(array); + continue; + } + if (property.NameEquals("top_logprobs"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(ChatTokenTopLogProbabilityDetails.DeserializeChatTokenTopLogProbabilityDetails(item, options)); } + topLogprobs = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatTokenLogProbabilityDetails(token, logprob, bytes, topLogprobs, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatTokenLogProbabilityDetails(token, logprob, bytes, topLogprobs, serializedAdditionalRawData); + } - ChatTokenLogProbabilityDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatTokenLogProbabilityDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatTokenLogProbabilityDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatTokenLogProbabilityDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatTokenLogProbabilityDetails(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatTokenLogProbabilityDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatTokenLogProbabilityDetails)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatTokenLogProbabilityDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatTokenLogProbabilityDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTokenLogProbabilityDetails.cs b/src/Generated/Models/ChatTokenLogProbabilityDetails.cs index 4443ad92..d4cc8461 100644 --- a/src/Generated/Models/ChatTokenLogProbabilityDetails.cs +++ b/src/Generated/Models/ChatTokenLogProbabilityDetails.cs @@ -6,35 +6,34 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTokenLogProbabilityDetails { - public partial class ChatTokenLogProbabilityDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ChatTokenLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes, IEnumerable topLogProbabilities) + { + Argument.AssertNotNull(token, nameof(token)); + Argument.AssertNotNull(topLogProbabilities, nameof(topLogProbabilities)); + + Token = token; + LogProbability = logProbability; + Utf8Bytes = utf8Bytes; + TopLogProbabilities = topLogProbabilities.ToList(); + } + + internal ChatTokenLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes, IReadOnlyList topLogProbabilities, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatTokenLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes, IEnumerable topLogProbabilities) - { - Argument.AssertNotNull(token, nameof(token)); - Argument.AssertNotNull(topLogProbabilities, nameof(topLogProbabilities)); - - Token = token; - LogProbability = logProbability; - Utf8Bytes = utf8Bytes; - TopLogProbabilities = topLogProbabilities.ToList(); - } - - internal ChatTokenLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes, IReadOnlyList topLogProbabilities, IDictionary serializedAdditionalRawData) - { - Token = token; - LogProbability = logProbability; - Utf8Bytes = utf8Bytes; - TopLogProbabilities = topLogProbabilities; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal ChatTokenLogProbabilityDetails() - { - } - - public string Token { get; } + Token = token; + LogProbability = logProbability; + Utf8Bytes = utf8Bytes; + TopLogProbabilities = topLogProbabilities; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal ChatTokenLogProbabilityDetails() + { + } + + public string Token { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTokenTopLogProbabilityDetails.Serialization.cs b/src/Generated/Models/ChatTokenTopLogProbabilityDetails.Serialization.cs index 6f72f1a4..ee1deb2d 100644 --- a/src/Generated/Models/ChatTokenTopLogProbabilityDetails.Serialization.cs +++ b/src/Generated/Models/ChatTokenTopLogProbabilityDetails.Serialization.cs @@ -8,171 +8,170 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTokenTopLogProbabilityDetails : IJsonModel { - public partial class ChatTokenTopLogProbabilityDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("token") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("token") != true) + { + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + } + if (SerializedAdditionalRawData?.ContainsKey("logprob") != true) + { + writer.WritePropertyName("logprob"u8); + writer.WriteNumberValue(LogProbability); + } + if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + { + if (Utf8Bytes != null) { - writer.WritePropertyName("token"u8); - writer.WriteStringValue(Token); + writer.WritePropertyName("bytes"u8); + writer.WriteStartArray(); + foreach (var item in Utf8Bytes.Value.Span) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("logprob") != true) + else { - writer.WritePropertyName("logprob"u8); - writer.WriteNumberValue(LogProbability); + writer.WriteNull("bytes"); } - if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Utf8Bytes != null) - { - writer.WritePropertyName("bytes"u8); - writer.WriteStartArray(); - foreach (var item in Utf8Bytes.Value.Span) - { - writer.WriteNumberValue(item); - } - writer.WriteEndArray(); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("bytes"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatTokenTopLogProbabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatTokenTopLogProbabilityDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatTokenTopLogProbabilityDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support reading '{format}' format."); } - internal static ChatTokenTopLogProbabilityDetails DeserializeChatTokenTopLogProbabilityDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatTokenTopLogProbabilityDetails(document.RootElement, options); + } + + internal static ChatTokenTopLogProbabilityDetails DeserializeChatTokenTopLogProbabilityDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string token = default; + float logprob = default; + ReadOnlyMemory? bytes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("token"u8)) { - return null; + token = property.Value.GetString(); + continue; } - string token = default; - float logprob = default; - ReadOnlyMemory? bytes = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("logprob"u8)) { - if (property.NameEquals("token"u8)) - { - token = property.Value.GetString(); - continue; - } - if (property.NameEquals("logprob"u8)) - { - logprob = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("bytes"u8)) + logprob = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("bytes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - int index = 0; - byte[] array = new byte[property.Value.GetArrayLength()]; - foreach (var item in property.Value.EnumerateArray()) - { - array[index] = item.GetByte(); - index++; - } - bytes = new ReadOnlyMemory?(array); continue; } - if (true) + int index = 0; + byte[] array = new byte[property.Value.GetArrayLength()]; + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array[index] = item.GetByte(); + index++; } + bytes = new ReadOnlyMemory?(array); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatTokenTopLogProbabilityDetails(token, logprob, bytes, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatTokenTopLogProbabilityDetails(token, logprob, bytes, serializedAdditionalRawData); + } - ChatTokenTopLogProbabilityDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatTokenTopLogProbabilityDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatTokenTopLogProbabilityDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatTokenTopLogProbabilityDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatTokenTopLogProbabilityDetails(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatTokenTopLogProbabilityDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatTokenTopLogProbabilityDetails)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatTokenTopLogProbabilityDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatTokenTopLogProbabilityDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTokenTopLogProbabilityDetails.cs b/src/Generated/Models/ChatTokenTopLogProbabilityDetails.cs index c02aa387..6a1e8fe7 100644 --- a/src/Generated/Models/ChatTokenTopLogProbabilityDetails.cs +++ b/src/Generated/Models/ChatTokenTopLogProbabilityDetails.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTokenTopLogProbabilityDetails { - public partial class ChatTokenTopLogProbabilityDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ChatTokenTopLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes) + { + Argument.AssertNotNull(token, nameof(token)); + + Token = token; + LogProbability = logProbability; + Utf8Bytes = utf8Bytes; + } + + internal ChatTokenTopLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatTokenTopLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes) - { - Argument.AssertNotNull(token, nameof(token)); - - Token = token; - LogProbability = logProbability; - Utf8Bytes = utf8Bytes; - } - - internal ChatTokenTopLogProbabilityDetails(string token, float logProbability, ReadOnlyMemory? utf8Bytes, IDictionary serializedAdditionalRawData) - { - Token = token; - LogProbability = logProbability; - Utf8Bytes = utf8Bytes; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal ChatTokenTopLogProbabilityDetails() - { - } - - public string Token { get; } + Token = token; + LogProbability = logProbability; + Utf8Bytes = utf8Bytes; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal ChatTokenTopLogProbabilityDetails() + { + } + + public string Token { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTokenUsage.Serialization.cs b/src/Generated/Models/ChatTokenUsage.Serialization.cs index 8a2854fb..3c8ca7a4 100644 --- a/src/Generated/Models/ChatTokenUsage.Serialization.cs +++ b/src/Generated/Models/ChatTokenUsage.Serialization.cs @@ -8,163 +8,162 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTokenUsage : IJsonModel { - public partial class ChatTokenUsage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) - { - writer.WritePropertyName("completion_tokens"u8); - writer.WriteNumberValue(OutputTokenCount); - } - if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) - { - writer.WritePropertyName("prompt_tokens"u8); - writer.WriteNumberValue(InputTokenCount); - } - if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) - { - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokenCount); - } - if (SerializedAdditionalRawData?.ContainsKey("completion_tokens_details") != true && Optional.IsDefined(OutputTokenDetails)) - { - writer.WritePropertyName("completion_tokens_details"u8); - writer.WriteObjectValue(OutputTokenDetails, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) + { + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(OutputTokenCount); + } + if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) + { + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(InputTokenCount); + } + if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) + { + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokenCount); + } + if (SerializedAdditionalRawData?.ContainsKey("completion_tokens_details") != true && Optional.IsDefined(OutputTokenDetails)) + { + writer.WritePropertyName("completion_tokens_details"u8); + writer.WriteObjectValue(OutputTokenDetails, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatTokenUsage(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support reading '{format}' format."); } - internal static ChatTokenUsage DeserializeChatTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatTokenUsage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static ChatTokenUsage DeserializeChatTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int completionTokens = default; + int promptTokens = default; + int totalTokens = default; + ChatOutputTokenUsageDetails completionTokensDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) { - return null; + completionTokens = property.Value.GetInt32(); + continue; } - int completionTokens = default; - int promptTokens = default; - int totalTokens = default; - ChatOutputTokenUsageDetails completionTokensDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("prompt_tokens"u8)) { - if (property.NameEquals("completion_tokens"u8)) - { - completionTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("prompt_tokens"u8)) - { - promptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total_tokens"u8)) - { - totalTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("completion_tokens_details"u8)) + promptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("total_tokens"u8)) + { + totalTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("completion_tokens_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - completionTokensDetails = ChatOutputTokenUsageDetails.DeserializeChatOutputTokenUsageDetails(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + completionTokensDetails = ChatOutputTokenUsageDetails.DeserializeChatOutputTokenUsageDetails(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatTokenUsage(completionTokens, promptTokens, totalTokens, completionTokensDetails, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatTokenUsage(completionTokens, promptTokens, totalTokens, completionTokensDetails, serializedAdditionalRawData); + } - ChatTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatTokenUsage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatTokenUsage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatTokenUsage(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatTokenUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatTokenUsage)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatTokenUsage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatTokenUsage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTokenUsage.cs b/src/Generated/Models/ChatTokenUsage.cs index 098738c9..40dbe256 100644 --- a/src/Generated/Models/ChatTokenUsage.cs +++ b/src/Generated/Models/ChatTokenUsage.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTokenUsage { - public partial class ChatTokenUsage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ChatTokenUsage(int outputTokenCount, int inputTokenCount, int totalTokenCount) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatTokenUsage(int outputTokenCount, int inputTokenCount, int totalTokenCount) - { - OutputTokenCount = outputTokenCount; - InputTokenCount = inputTokenCount; - TotalTokenCount = totalTokenCount; - } + OutputTokenCount = outputTokenCount; + InputTokenCount = inputTokenCount; + TotalTokenCount = totalTokenCount; + } - internal ChatTokenUsage(int outputTokenCount, int inputTokenCount, int totalTokenCount, ChatOutputTokenUsageDetails outputTokenDetails, IDictionary serializedAdditionalRawData) - { - OutputTokenCount = outputTokenCount; - InputTokenCount = inputTokenCount; - TotalTokenCount = totalTokenCount; - OutputTokenDetails = outputTokenDetails; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ChatTokenUsage(int outputTokenCount, int inputTokenCount, int totalTokenCount, ChatOutputTokenUsageDetails outputTokenDetails, IDictionary serializedAdditionalRawData) + { + OutputTokenCount = outputTokenCount; + InputTokenCount = inputTokenCount; + TotalTokenCount = totalTokenCount; + OutputTokenDetails = outputTokenDetails; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ChatTokenUsage() - { - } + internal ChatTokenUsage() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTool.Serialization.cs b/src/Generated/Models/ChatTool.Serialization.cs index 78fbf981..c5a223bc 100644 --- a/src/Generated/Models/ChatTool.Serialization.cs +++ b/src/Generated/Models/ChatTool.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTool : IJsonModel { - public partial class ChatTool : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTool)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatTool)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Kind.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("function") != true) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Kind.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("function") != true) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatTool)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatTool(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatTool)} does not support reading '{format}' format."); } - internal static ChatTool DeserializeChatTool(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatTool(document.RootElement, options); + } + + internal static ChatTool DeserializeChatTool(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatToolKind type = default; + InternalFunctionDefinition function = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = new ChatToolKind(property.Value.GetString()); + continue; } - ChatToolKind type = default; - InternalFunctionDefinition function = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("function"u8)) { - if (property.NameEquals("type"u8)) - { - type = new ChatToolKind(property.Value.GetString()); - continue; - } - if (property.NameEquals("function"u8)) - { - function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatTool(type, function, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatTool)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatTool(type, function, serializedAdditionalRawData); + } - ChatTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatTool(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatTool)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatTool)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatTool FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatTool(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatTool)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatTool FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatTool(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatTool.cs b/src/Generated/Models/ChatTool.cs index d10b8bc5..01d86bc2 100644 --- a/src/Generated/Models/ChatTool.cs +++ b/src/Generated/Models/ChatTool.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatTool { - public partial class ChatTool - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatTool(ChatToolKind kind, InternalFunctionDefinition function, IDictionary serializedAdditionalRawData) - { - Kind = kind; - Function = function; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ChatTool(ChatToolKind kind, InternalFunctionDefinition function, IDictionary serializedAdditionalRawData) + { + Kind = kind; + Function = function; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ChatTool() - { - } + internal ChatTool() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatToolCall.Serialization.cs b/src/Generated/Models/ChatToolCall.Serialization.cs index 0b17701a..5fa144d2 100644 --- a/src/Generated/Models/ChatToolCall.Serialization.cs +++ b/src/Generated/Models/ChatToolCall.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatToolCall : IJsonModel { - public partial class ChatToolCall : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatToolCall)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ChatToolCall)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Kind.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("function") != true) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Kind.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("function") != true) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ChatToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatToolCall(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatToolCall)} does not support reading '{format}' format."); } - internal static ChatToolCall DeserializeChatToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatToolCall(document.RootElement, options); + } + + internal static ChatToolCall DeserializeChatToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + ChatToolCallKind type = default; + InternalChatCompletionMessageToolCallFunction function = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - ChatToolCallKind type = default; - InternalChatCompletionMessageToolCallFunction function = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ChatToolCallKind(property.Value.GetString()); - continue; - } - if (property.NameEquals("function"u8)) - { - function = InternalChatCompletionMessageToolCallFunction.DeserializeInternalChatCompletionMessageToolCallFunction(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = new ChatToolCallKind(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ChatToolCall(id, type, function, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("function"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatToolCall)} does not support writing '{options.Format}' format."); + function = InternalChatCompletionMessageToolCallFunction.DeserializeInternalChatCompletionMessageToolCallFunction(property.Value, options); + continue; } - } - - ChatToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatToolCall)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ChatToolCall(id, type, function, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatToolCall FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatToolCall(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatToolCall)} does not support writing '{options.Format}' format."); } + } + + ChatToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatToolCall)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatToolCall FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatToolCall(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatToolCall.cs b/src/Generated/Models/ChatToolCall.cs index 0d909e90..9f9e8a00 100644 --- a/src/Generated/Models/ChatToolCall.cs +++ b/src/Generated/Models/ChatToolCall.cs @@ -5,24 +5,23 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat -{ - public partial class ChatToolCall - { - internal IDictionary SerializedAdditionalRawData { get; set; } +namespace OpenAI.Chat; - internal ChatToolCall(string id, ChatToolCallKind kind, InternalChatCompletionMessageToolCallFunction function, IDictionary serializedAdditionalRawData) - { - Id = id; - Kind = kind; - Function = function; - SerializedAdditionalRawData = serializedAdditionalRawData; - } +public partial class ChatToolCall +{ + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ChatToolCall() - { - } + internal ChatToolCall(string id, ChatToolCallKind kind, InternalChatCompletionMessageToolCallFunction function, IDictionary serializedAdditionalRawData) + { + Id = id; + Kind = kind; + Function = function; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string Id { get; set; } + internal ChatToolCall() + { } -} + + public string Id { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatToolCallKind.cs b/src/Generated/Models/ChatToolCallKind.cs index c75e67ca..b5e31000 100644 --- a/src/Generated/Models/ChatToolCallKind.cs +++ b/src/Generated/Models/ChatToolCallKind.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public readonly partial struct ChatToolCallKind : IEquatable { - public readonly partial struct ChatToolCallKind : IEquatable - { - private readonly string _value; + private readonly string _value; - public ChatToolCallKind(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public ChatToolCallKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FunctionValue = "function"; + private const string FunctionValue = "function"; - public static ChatToolCallKind Function { get; } = new ChatToolCallKind(FunctionValue); - public static bool operator ==(ChatToolCallKind left, ChatToolCallKind right) => left.Equals(right); - public static bool operator !=(ChatToolCallKind left, ChatToolCallKind right) => !left.Equals(right); - public static implicit operator ChatToolCallKind(string value) => new ChatToolCallKind(value); + public static ChatToolCallKind Function { get; } = new ChatToolCallKind(FunctionValue); + public static bool operator ==(ChatToolCallKind left, ChatToolCallKind right) => left.Equals(right); + public static bool operator !=(ChatToolCallKind left, ChatToolCallKind right) => !left.Equals(right); + public static implicit operator ChatToolCallKind(string value) => new ChatToolCallKind(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ChatToolCallKind other && Equals(other); - public bool Equals(ChatToolCallKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatToolCallKind other && Equals(other); + public bool Equals(ChatToolCallKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/ChatToolChoice.Serialization.cs b/src/Generated/Models/ChatToolChoice.Serialization.cs index 9fd54096..c86594b4 100644 --- a/src/Generated/Models/ChatToolChoice.Serialization.cs +++ b/src/Generated/Models/ChatToolChoice.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatToolChoice : IJsonModel { - public partial class ChatToolChoice : IJsonModel + ChatToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ChatToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatToolChoice)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatToolChoice(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatToolChoice)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatToolChoice(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatToolChoice)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - ChatToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatToolChoice(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatToolChoice)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatToolChoice)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ChatToolChoice FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatToolChoice(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatToolChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatToolChoice)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ChatToolChoice FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeChatToolChoice(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ChatToolChoice.cs b/src/Generated/Models/ChatToolChoice.cs index 5650611a..8bdac0ab 100644 --- a/src/Generated/Models/ChatToolChoice.cs +++ b/src/Generated/Models/ChatToolChoice.cs @@ -5,10 +5,9 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ChatToolChoice { - public partial class ChatToolChoice - { - internal IDictionary SerializedAdditionalRawData { get; set; } - } -} + internal IDictionary SerializedAdditionalRawData { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ChatToolKind.cs b/src/Generated/Models/ChatToolKind.cs index 793f2f7a..f04c7fd1 100644 --- a/src/Generated/Models/ChatToolKind.cs +++ b/src/Generated/Models/ChatToolKind.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public readonly partial struct ChatToolKind : IEquatable { - public readonly partial struct ChatToolKind : IEquatable - { - private readonly string _value; + private readonly string _value; - public ChatToolKind(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public ChatToolKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FunctionValue = "function"; + private const string FunctionValue = "function"; - public static ChatToolKind Function { get; } = new ChatToolKind(FunctionValue); - public static bool operator ==(ChatToolKind left, ChatToolKind right) => left.Equals(right); - public static bool operator !=(ChatToolKind left, ChatToolKind right) => !left.Equals(right); - public static implicit operator ChatToolKind(string value) => new ChatToolKind(value); + public static ChatToolKind Function { get; } = new ChatToolKind(FunctionValue); + public static bool operator ==(ChatToolKind left, ChatToolKind right) => left.Equals(right); + public static bool operator !=(ChatToolKind left, ChatToolKind right) => !left.Equals(right); + public static implicit operator ChatToolKind(string value) => new ChatToolKind(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is ChatToolKind other && Equals(other); - public bool Equals(ChatToolKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatToolKind other && Equals(other); + public bool Equals(ChatToolKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/CodeInterpreterToolDefinition.Serialization.cs b/src/Generated/Models/CodeInterpreterToolDefinition.Serialization.cs index c1f2296d..acf74b62 100644 --- a/src/Generated/Models/CodeInterpreterToolDefinition.Serialization.cs +++ b/src/Generated/Models/CodeInterpreterToolDefinition.Serialization.cs @@ -8,90 +8,89 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class CodeInterpreterToolDefinition : IJsonModel { - public partial class CodeInterpreterToolDefinition : IJsonModel + CodeInterpreterToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - CodeInterpreterToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support reading '{format}' format."); } - internal static CodeInterpreterToolDefinition DeserializeCodeInterpreterToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CodeInterpreterToolDefinition(type, serializedAdditionalRawData); - } + internal static CodeInterpreterToolDefinition DeserializeCodeInterpreterToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support writing '{options.Format}' format."); - } + return null; } - - CodeInterpreterToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new CodeInterpreterToolDefinition(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new CodeInterpreterToolDefinition FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeCodeInterpreterToolDefinition(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support writing '{options.Format}' format."); } + } + + CodeInterpreterToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCodeInterpreterToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolDefinition)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new CodeInterpreterToolDefinition FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCodeInterpreterToolDefinition(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/CodeInterpreterToolDefinition.cs b/src/Generated/Models/CodeInterpreterToolDefinition.cs index 1b330ab0..b4d9dc49 100644 --- a/src/Generated/Models/CodeInterpreterToolDefinition.cs +++ b/src/Generated/Models/CodeInterpreterToolDefinition.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class CodeInterpreterToolDefinition : ToolDefinition { - public partial class CodeInterpreterToolDefinition : ToolDefinition + public CodeInterpreterToolDefinition() { - public CodeInterpreterToolDefinition() - { - Type = "code_interpreter"; - } + Type = "code_interpreter"; + } - internal CodeInterpreterToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal CodeInterpreterToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/CodeInterpreterToolResources.Serialization.cs b/src/Generated/Models/CodeInterpreterToolResources.Serialization.cs index 467dad78..b123b17c 100644 --- a/src/Generated/Models/CodeInterpreterToolResources.Serialization.cs +++ b/src/Generated/Models/CodeInterpreterToolResources.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class CodeInterpreterToolResources : IJsonModel { - public partial class CodeInterpreterToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - CodeInterpreterToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + CodeInterpreterToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCodeInterpreterToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support reading '{format}' format."); } - internal static CodeInterpreterToolResources DeserializeCodeInterpreterToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeInterpreterToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static CodeInterpreterToolResources DeserializeCodeInterpreterToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + fileIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new CodeInterpreterToolResources(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new CodeInterpreterToolResources(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - CodeInterpreterToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeCodeInterpreterToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + CodeInterpreterToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static CodeInterpreterToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeCodeInterpreterToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCodeInterpreterToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static CodeInterpreterToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCodeInterpreterToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/CodeInterpreterToolResources.cs b/src/Generated/Models/CodeInterpreterToolResources.cs index 1735ff0f..c268dfd7 100644 --- a/src/Generated/Models/CodeInterpreterToolResources.cs +++ b/src/Generated/Models/CodeInterpreterToolResources.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class CodeInterpreterToolResources { - public partial class CodeInterpreterToolResources - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal CodeInterpreterToolResources(IList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal CodeInterpreterToolResources(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/Embedding.Serialization.cs b/src/Generated/Models/Embedding.Serialization.cs index 93a723fe..ecab2161 100644 --- a/src/Generated/Models/Embedding.Serialization.cs +++ b/src/Generated/Models/Embedding.Serialization.cs @@ -8,155 +8,154 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +public partial class Embedding : IJsonModel { - public partial class Embedding : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(Embedding)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(Embedding)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("embedding") != true) - { - writer.WritePropertyName("embedding"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("embedding") != true) + { + writer.WritePropertyName("embedding"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(EmbeddingProperty); #else - using (JsonDocument document = JsonDocument.Parse(EmbeddingProperty)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + using (JsonDocument document = JsonDocument.Parse(EmbeddingProperty)) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - Embedding IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + Embedding IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(Embedding)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeEmbedding(document.RootElement, options); + throw new FormatException($"The model {nameof(Embedding)} does not support reading '{format}' format."); } - internal static Embedding DeserializeEmbedding(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmbedding(document.RootElement, options); + } + + internal static Embedding DeserializeEmbedding(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + BinaryData embedding = default; + InternalEmbeddingObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - BinaryData embedding = default; - InternalEmbeddingObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("embedding"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("embedding"u8)) - { - embedding = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalEmbeddingObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + embedding = BinaryData.FromString(property.Value.GetRawText()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new Embedding(index, embedding, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(Embedding)} does not support writing '{options.Format}' format."); + @object = new InternalEmbeddingObject(property.Value.GetString()); + continue; } - } - - Embedding IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeEmbedding(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(Embedding)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new Embedding(index, embedding, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static Embedding FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeEmbedding(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Embedding)} does not support writing '{options.Format}' format."); } + } + + Embedding IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEmbedding(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Embedding)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static Embedding FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEmbedding(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/Embedding.cs b/src/Generated/Models/Embedding.cs index b8eb1097..03872aa9 100644 --- a/src/Generated/Models/Embedding.cs +++ b/src/Generated/Models/Embedding.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Embeddings -{ - public partial class Embedding - { - internal IDictionary SerializedAdditionalRawData { get; set; } +namespace OpenAI.Embeddings; - internal Embedding() - { - } +public partial class Embedding +{ + internal IDictionary SerializedAdditionalRawData { get; set; } - public int Index { get; } + internal Embedding() + { } -} + + public int Index { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/EmbeddingCollection.Serialization.cs b/src/Generated/Models/EmbeddingCollection.Serialization.cs index d569d559..6c23b3fd 100644 --- a/src/Generated/Models/EmbeddingCollection.Serialization.cs +++ b/src/Generated/Models/EmbeddingCollection.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +public partial class EmbeddingCollection : IJsonModel { - public partial class EmbeddingCollection : IJsonModel + EmbeddingCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - EmbeddingCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(EmbeddingCollection)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeEmbeddingCollection(document.RootElement, options); + throw new FormatException($"The model {nameof(EmbeddingCollection)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmbeddingCollection(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(EmbeddingCollection)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - EmbeddingCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeEmbeddingCollection(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(EmbeddingCollection)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EmbeddingCollection)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + EmbeddingCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static EmbeddingCollection FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeEmbeddingCollection(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEmbeddingCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmbeddingCollection)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static EmbeddingCollection FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEmbeddingCollection(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/EmbeddingCollection.cs b/src/Generated/Models/EmbeddingCollection.cs index 6afd1cf9..17e541ca 100644 --- a/src/Generated/Models/EmbeddingCollection.cs +++ b/src/Generated/Models/EmbeddingCollection.cs @@ -6,12 +6,11 @@ using System.Collections.ObjectModel; using System.Linq; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +public partial class EmbeddingCollection : ReadOnlyCollection { - public partial class EmbeddingCollection : ReadOnlyCollection - { - public string Model { get; } + public string Model { get; } - public EmbeddingTokenUsage Usage { get; } - } -} + public EmbeddingTokenUsage Usage { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/EmbeddingGenerationOptions.Serialization.cs b/src/Generated/Models/EmbeddingGenerationOptions.Serialization.cs index 5a2ee5c1..9ea51fc3 100644 --- a/src/Generated/Models/EmbeddingGenerationOptions.Serialization.cs +++ b/src/Generated/Models/EmbeddingGenerationOptions.Serialization.cs @@ -8,191 +8,190 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +public partial class EmbeddingGenerationOptions : IJsonModel { - public partial class EmbeddingGenerationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("input") != true) - { - writer.WritePropertyName("input"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("input") != true) + { + writer.WritePropertyName("input"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Input); #else - using (JsonDocument document = JsonDocument.Parse(Input)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + using (JsonDocument document = JsonDocument.Parse(Input)) { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.ToString()); + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData?.ContainsKey("encoding_format") != true && Optional.IsDefined(EncodingFormat)) - { - writer.WritePropertyName("encoding_format"u8); - writer.WriteStringValue(EncodingFormat.Value.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("dimensions") != true && Optional.IsDefined(Dimensions)) - { - writer.WritePropertyName("dimensions"u8); - writer.WriteNumberValue(Dimensions.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) - { - writer.WritePropertyName("user"u8); - writer.WriteStringValue(EndUserId); - } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("encoding_format") != true && Optional.IsDefined(EncodingFormat)) + { + writer.WritePropertyName("encoding_format"u8); + writer.WriteStringValue(EncodingFormat.Value.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("dimensions") != true && Optional.IsDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"u8); + writer.WriteNumberValue(Dimensions.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(EndUserId); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - EmbeddingGenerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + EmbeddingGenerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeEmbeddingGenerationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support reading '{format}' format."); } - internal static EmbeddingGenerationOptions DeserializeEmbeddingGenerationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmbeddingGenerationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static EmbeddingGenerationOptions DeserializeEmbeddingGenerationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData input = default; + InternalCreateEmbeddingRequestModel model = default; + InternalCreateEmbeddingRequestEncodingFormat? encodingFormat = default; + int? dimensions = default; + string user = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input"u8)) { - return null; + input = BinaryData.FromString(property.Value.GetRawText()); + continue; } - BinaryData input = default; - InternalCreateEmbeddingRequestModel model = default; - InternalCreateEmbeddingRequestEncodingFormat? encodingFormat = default; - int? dimensions = default; - string user = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("model"u8)) { - if (property.NameEquals("input"u8)) - { - input = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("model"u8)) - { - model = new InternalCreateEmbeddingRequestModel(property.Value.GetString()); - continue; - } - if (property.NameEquals("encoding_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - encodingFormat = new InternalCreateEmbeddingRequestEncodingFormat(property.Value.GetString()); - continue; - } - if (property.NameEquals("dimensions"u8)) + model = new InternalCreateEmbeddingRequestModel(property.Value.GetString()); + continue; + } + if (property.NameEquals("encoding_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dimensions = property.Value.GetInt32(); continue; } - if (property.NameEquals("user"u8)) + encodingFormat = new InternalCreateEmbeddingRequestEncodingFormat(property.Value.GetString()); + continue; + } + if (property.NameEquals("dimensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - user = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + dimensions = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new EmbeddingGenerationOptions( - input, - model, - encodingFormat, - dimensions, - user, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("user"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support writing '{options.Format}' format."); + user = property.Value.GetString(); + continue; } - } - - EmbeddingGenerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeEmbeddingGenerationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new EmbeddingGenerationOptions( + input, + model, + encodingFormat, + dimensions, + user, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static EmbeddingGenerationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeEmbeddingGenerationOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support writing '{options.Format}' format."); } + } + + EmbeddingGenerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEmbeddingGenerationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmbeddingGenerationOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static EmbeddingGenerationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEmbeddingGenerationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/EmbeddingGenerationOptions.cs b/src/Generated/Models/EmbeddingGenerationOptions.cs index 92ffbca2..452fda88 100644 --- a/src/Generated/Models/EmbeddingGenerationOptions.cs +++ b/src/Generated/Models/EmbeddingGenerationOptions.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +public partial class EmbeddingGenerationOptions { - public partial class EmbeddingGenerationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal EmbeddingGenerationOptions(BinaryData input, InternalCreateEmbeddingRequestModel model, InternalCreateEmbeddingRequestEncodingFormat? encodingFormat, int? dimensions, string endUserId, IDictionary serializedAdditionalRawData) - { - Input = input; - Model = model; - EncodingFormat = encodingFormat; - Dimensions = dimensions; - EndUserId = endUserId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public int? Dimensions { get; set; } + internal EmbeddingGenerationOptions(BinaryData input, InternalCreateEmbeddingRequestModel model, InternalCreateEmbeddingRequestEncodingFormat? encodingFormat, int? dimensions, string endUserId, IDictionary serializedAdditionalRawData) + { + Input = input; + Model = model; + EncodingFormat = encodingFormat; + Dimensions = dimensions; + EndUserId = endUserId; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public int? Dimensions { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/EmbeddingTokenUsage.Serialization.cs b/src/Generated/Models/EmbeddingTokenUsage.Serialization.cs index 52037989..ed0534e7 100644 --- a/src/Generated/Models/EmbeddingTokenUsage.Serialization.cs +++ b/src/Generated/Models/EmbeddingTokenUsage.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +public partial class EmbeddingTokenUsage : IJsonModel { - public partial class EmbeddingTokenUsage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) - { - writer.WritePropertyName("prompt_tokens"u8); - writer.WriteNumberValue(InputTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) - { - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) + { + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(InputTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) + { + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - EmbeddingTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + EmbeddingTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeEmbeddingTokenUsage(document.RootElement, options); + throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support reading '{format}' format."); } - internal static EmbeddingTokenUsage DeserializeEmbeddingTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEmbeddingTokenUsage(document.RootElement, options); + } + + internal static EmbeddingTokenUsage DeserializeEmbeddingTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int promptTokens = default; + int totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("prompt_tokens"u8)) { - return null; + promptTokens = property.Value.GetInt32(); + continue; } - int promptTokens = default; - int totalTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("total_tokens"u8)) { - if (property.NameEquals("prompt_tokens"u8)) - { - promptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total_tokens"u8)) - { - totalTokens = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + totalTokens = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new EmbeddingTokenUsage(promptTokens, totalTokens, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new EmbeddingTokenUsage(promptTokens, totalTokens, serializedAdditionalRawData); + } - EmbeddingTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeEmbeddingTokenUsage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + EmbeddingTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static EmbeddingTokenUsage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeEmbeddingTokenUsage(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEmbeddingTokenUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EmbeddingTokenUsage)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static EmbeddingTokenUsage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEmbeddingTokenUsage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/EmbeddingTokenUsage.cs b/src/Generated/Models/EmbeddingTokenUsage.cs index 5234ccde..c2ae19a8 100644 --- a/src/Generated/Models/EmbeddingTokenUsage.cs +++ b/src/Generated/Models/EmbeddingTokenUsage.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +public partial class EmbeddingTokenUsage { - public partial class EmbeddingTokenUsage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal EmbeddingTokenUsage(int inputTokens, int totalTokens) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal EmbeddingTokenUsage(int inputTokens, int totalTokens) - { - InputTokens = inputTokens; - TotalTokens = totalTokens; - } + InputTokens = inputTokens; + TotalTokens = totalTokens; + } - internal EmbeddingTokenUsage(int inputTokens, int totalTokens, IDictionary serializedAdditionalRawData) - { - InputTokens = inputTokens; - TotalTokens = totalTokens; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal EmbeddingTokenUsage(int inputTokens, int totalTokens, IDictionary serializedAdditionalRawData) + { + InputTokens = inputTokens; + TotalTokens = totalTokens; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal EmbeddingTokenUsage() - { - } - public int TotalTokens { get; } + internal EmbeddingTokenUsage() + { } -} + public int TotalTokens { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/FileChunkingStrategy.Serialization.cs b/src/Generated/Models/FileChunkingStrategy.Serialization.cs index c56c5329..5fc19bf1 100644 --- a/src/Generated/Models/FileChunkingStrategy.Serialization.cs +++ b/src/Generated/Models/FileChunkingStrategy.Serialization.cs @@ -7,119 +7,118 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +[PersistableModelProxy(typeof(InternalUnknownFileChunkingStrategyResponseParamProxy))] +public partial class FileChunkingStrategy : IJsonModel { - [PersistableModelProxy(typeof(InternalUnknownFileChunkingStrategyResponseParamProxy))] - public partial class FileChunkingStrategy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileChunkingStrategy(document.RootElement, options); + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{format}' format."); } - internal static FileChunkingStrategy DeserializeFileChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "auto": return InternalAutoChunkingStrategy.DeserializeInternalAutoChunkingStrategy(element, options); - case "other": return InternalUnknownChunkingStrategy.DeserializeInternalUnknownChunkingStrategy(element, options); - case "static": return StaticFileChunkingStrategy.DeserializeStaticFileChunkingStrategy(element, options); - } - } - return InternalUnknownFileChunkingStrategyResponseParamProxy.DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(element, options); - } + internal static FileChunkingStrategy DeserializeFileChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{options.Format}' format."); - } + return null; } - - FileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFileChunkingStrategy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{options.Format}' format."); + case "auto": return InternalAutoChunkingStrategy.DeserializeInternalAutoChunkingStrategy(element, options); + case "other": return InternalUnknownChunkingStrategy.DeserializeInternalUnknownChunkingStrategy(element, options); + case "static": return StaticFileChunkingStrategy.DeserializeStaticFileChunkingStrategy(element, options); } } + return InternalUnknownFileChunkingStrategyResponseParamProxy.DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FileChunkingStrategy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFileChunkingStrategy(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + FileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FileChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileChunkingStrategy(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FileChunkingStrategy.cs b/src/Generated/Models/FileChunkingStrategy.cs index b93a33e9..30a6e439 100644 --- a/src/Generated/Models/FileChunkingStrategy.cs +++ b/src/Generated/Models/FileChunkingStrategy.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public abstract partial class FileChunkingStrategy { - public abstract partial class FileChunkingStrategy + internal IDictionary SerializedAdditionalRawData { get; set; } + protected FileChunkingStrategy() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected FileChunkingStrategy() - { - } - - internal FileChunkingStrategy(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal FileChunkingStrategy(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/FileDeletionResult.Serialization.cs b/src/Generated/Models/FileDeletionResult.Serialization.cs index 6a51e840..42132d97 100644 --- a/src/Generated/Models/FileDeletionResult.Serialization.cs +++ b/src/Generated/Models/FileDeletionResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +public partial class FileDeletionResult : IJsonModel { - public partial class FileDeletionResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileDeletionResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FileDeletionResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) - { - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) + { + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FileDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FileDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileDeletionResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileDeletionResult(document.RootElement, options); + throw new FormatException($"The model {nameof(FileDeletionResult)} does not support reading '{format}' format."); } - internal static FileDeletionResult DeserializeFileDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileDeletionResult(document.RootElement, options); + } + + internal static FileDeletionResult DeserializeFileDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalDeleteFileResponseObject @object = default; + bool deleted = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalDeleteFileResponseObject @object = default; - bool deleted = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalDeleteFileResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + @object = new InternalDeleteFileResponseObject(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FileDeletionResult(id, @object, deleted, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("deleted"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FileDeletionResult)} does not support writing '{options.Format}' format."); + deleted = property.Value.GetBoolean(); + continue; } - } - - FileDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFileDeletionResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileDeletionResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FileDeletionResult(id, @object, deleted, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FileDeletionResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFileDeletionResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileDeletionResult)} does not support writing '{options.Format}' format."); } + } + + FileDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileDeletionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileDeletionResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FileDeletionResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileDeletionResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FileDeletionResult.cs b/src/Generated/Models/FileDeletionResult.cs index 55bab610..15dce8ba 100644 --- a/src/Generated/Models/FileDeletionResult.cs +++ b/src/Generated/Models/FileDeletionResult.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Files +namespace OpenAI.Files; + +public partial class FileDeletionResult { - public partial class FileDeletionResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal FileDeletionResult(string fileId, bool deleted) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + Deleted = deleted; + } + + internal FileDeletionResult(string fileId, InternalDeleteFileResponseObject @object, bool deleted, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal FileDeletionResult(string fileId, bool deleted) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - Deleted = deleted; - } - - internal FileDeletionResult(string fileId, InternalDeleteFileResponseObject @object, bool deleted, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Object = @object; - Deleted = deleted; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal FileDeletionResult() - { - } - - public bool Deleted { get; } + FileId = fileId; + Object = @object; + Deleted = deleted; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal FileDeletionResult() + { + } + + public bool Deleted { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/FileFromStoreRemovalResult.Serialization.cs b/src/Generated/Models/FileFromStoreRemovalResult.Serialization.cs index a9d34f8f..1c9b5fc1 100644 --- a/src/Generated/Models/FileFromStoreRemovalResult.Serialization.cs +++ b/src/Generated/Models/FileFromStoreRemovalResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class FileFromStoreRemovalResult : IJsonModel { - public partial class FileFromStoreRemovalResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) - { - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Removed); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) + { + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Removed); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FileFromStoreRemovalResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FileFromStoreRemovalResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileFromStoreRemovalResult(document.RootElement, options); + throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support reading '{format}' format."); } - internal static FileFromStoreRemovalResult DeserializeFileFromStoreRemovalResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileFromStoreRemovalResult(document.RootElement, options); + } + + internal static FileFromStoreRemovalResult DeserializeFileFromStoreRemovalResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalDeleteVectorStoreFileResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - bool deleted = default; - InternalDeleteVectorStoreFileResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("deleted"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalDeleteVectorStoreFileResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + deleted = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FileFromStoreRemovalResult(id, deleted, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support writing '{options.Format}' format."); + @object = new InternalDeleteVectorStoreFileResponseObject(property.Value.GetString()); + continue; } - } - - FileFromStoreRemovalResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFileFromStoreRemovalResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FileFromStoreRemovalResult(id, deleted, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FileFromStoreRemovalResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFileFromStoreRemovalResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support writing '{options.Format}' format."); } + } + + FileFromStoreRemovalResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileFromStoreRemovalResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileFromStoreRemovalResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FileFromStoreRemovalResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileFromStoreRemovalResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FileFromStoreRemovalResult.cs b/src/Generated/Models/FileFromStoreRemovalResult.cs index 501e1057..1b78c9e0 100644 --- a/src/Generated/Models/FileFromStoreRemovalResult.cs +++ b/src/Generated/Models/FileFromStoreRemovalResult.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class FileFromStoreRemovalResult { - public partial class FileFromStoreRemovalResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal FileFromStoreRemovalResult(string fileId, bool removed) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal FileFromStoreRemovalResult(string fileId, bool removed) - { - Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(fileId, nameof(fileId)); - FileId = fileId; - Removed = removed; - } + FileId = fileId; + Removed = removed; + } - internal FileFromStoreRemovalResult(string fileId, bool removed, InternalDeleteVectorStoreFileResponseObject @object, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Removed = removed; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal FileFromStoreRemovalResult(string fileId, bool removed, InternalDeleteVectorStoreFileResponseObject @object, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Removed = removed; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal FileFromStoreRemovalResult() - { - } + internal FileFromStoreRemovalResult() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FileSearchRanker.cs b/src/Generated/Models/FileSearchRanker.cs index a1d8262c..183b91e1 100644 --- a/src/Generated/Models/FileSearchRanker.cs +++ b/src/Generated/Models/FileSearchRanker.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct FileSearchRanker : IEquatable { - public readonly partial struct FileSearchRanker : IEquatable - { - private readonly string _value; + private readonly string _value; - public FileSearchRanker(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public FileSearchRanker(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; - private const string Default20240821Value = "default_2024_08_21"; + private const string AutoValue = "auto"; + private const string Default20240821Value = "default_2024_08_21"; - public static FileSearchRanker Auto { get; } = new FileSearchRanker(AutoValue); - public static FileSearchRanker Default20240821 { get; } = new FileSearchRanker(Default20240821Value); - public static bool operator ==(FileSearchRanker left, FileSearchRanker right) => left.Equals(right); - public static bool operator !=(FileSearchRanker left, FileSearchRanker right) => !left.Equals(right); - public static implicit operator FileSearchRanker(string value) => new FileSearchRanker(value); + public static FileSearchRanker Auto { get; } = new FileSearchRanker(AutoValue); + public static FileSearchRanker Default20240821 { get; } = new FileSearchRanker(Default20240821Value); + public static bool operator ==(FileSearchRanker left, FileSearchRanker right) => left.Equals(right); + public static bool operator !=(FileSearchRanker left, FileSearchRanker right) => !left.Equals(right); + public static implicit operator FileSearchRanker(string value) => new FileSearchRanker(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FileSearchRanker other && Equals(other); - public bool Equals(FileSearchRanker other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileSearchRanker other && Equals(other); + public bool Equals(FileSearchRanker other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/FileSearchRankingOptions.Serialization.cs b/src/Generated/Models/FileSearchRankingOptions.Serialization.cs index 82356b1f..c42f1586 100644 --- a/src/Generated/Models/FileSearchRankingOptions.Serialization.cs +++ b/src/Generated/Models/FileSearchRankingOptions.Serialization.cs @@ -8,141 +8,140 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FileSearchRankingOptions : IJsonModel { - public partial class FileSearchRankingOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("ranker") != true && Optional.IsDefined(Ranker)) - { - writer.WritePropertyName("ranker"u8); - writer.WriteStringValue(Ranker.Value.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("score_threshold") != true) - { - writer.WritePropertyName("score_threshold"u8); - writer.WriteNumberValue(_scoreThreshold); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("ranker") != true && Optional.IsDefined(Ranker)) + { + writer.WritePropertyName("ranker"u8); + writer.WriteStringValue(Ranker.Value.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("score_threshold") != true) + { + writer.WritePropertyName("score_threshold"u8); + writer.WriteNumberValue(_scoreThreshold); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FileSearchRankingOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FileSearchRankingOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchRankingOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support reading '{format}' format."); } - internal static FileSearchRankingOptions DeserializeFileSearchRankingOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchRankingOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - FileSearchRanker? ranker = default; - float scoreThreshold = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static FileSearchRankingOptions DeserializeFileSearchRankingOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FileSearchRanker? ranker = default; + float scoreThreshold = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ranker"u8)) { - if (property.NameEquals("ranker"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - ranker = new FileSearchRanker(property.Value.GetString()); - continue; - } - if (property.NameEquals("score_threshold"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - scoreThreshold = property.Value.GetSingle(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + ranker = new FileSearchRanker(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FileSearchRankingOptions(ranker, scoreThreshold, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("score_threshold"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support writing '{options.Format}' format."); + scoreThreshold = property.Value.GetSingle(); + continue; } - } - - FileSearchRankingOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFileSearchRankingOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchRankingOptions(ranker, scoreThreshold, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FileSearchRankingOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFileSearchRankingOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + FileSearchRankingOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileSearchRankingOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchRankingOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FileSearchRankingOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileSearchRankingOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FileSearchRankingOptions.cs b/src/Generated/Models/FileSearchRankingOptions.cs index 0a498f2f..bbd9bc7b 100644 --- a/src/Generated/Models/FileSearchRankingOptions.cs +++ b/src/Generated/Models/FileSearchRankingOptions.cs @@ -5,12 +5,11 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FileSearchRankingOptions { - public partial class FileSearchRankingOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - public FileSearchRanker? Ranker { get; set; } - } -} + public FileSearchRanker? Ranker { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/FileSearchToolDefinition.Serialization.cs b/src/Generated/Models/FileSearchToolDefinition.Serialization.cs index 23868744..1e8ddd7a 100644 --- a/src/Generated/Models/FileSearchToolDefinition.Serialization.cs +++ b/src/Generated/Models/FileSearchToolDefinition.Serialization.cs @@ -8,100 +8,99 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FileSearchToolDefinition : IJsonModel { - public partial class FileSearchToolDefinition : IJsonModel + FileSearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - FileSearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchToolDefinition(document.RootElement, options); + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{format}' format."); } - internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolDefinition(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalAssistantToolsFileSearchFileSearch fileSearch = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalAssistantToolsFileSearchFileSearch fileSearch = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_search"u8)) { - if (property.NameEquals("file_search"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = InternalAssistantToolsFileSearchFileSearch.DeserializeInternalAssistantToolsFileSearchFileSearch(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = InternalAssistantToolsFileSearchFileSearch.DeserializeInternalAssistantToolsFileSearchFileSearch(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FileSearchToolDefinition(type, serializedAdditionalRawData, fileSearch); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - FileSearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFileSearchToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolDefinition(type, serializedAdditionalRawData, fileSearch); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new FileSearchToolDefinition FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFileSearchToolDefinition(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support writing '{options.Format}' format."); } + } + + FileSearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileSearchToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new FileSearchToolDefinition FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileSearchToolDefinition(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FileSearchToolDefinition.cs b/src/Generated/Models/FileSearchToolDefinition.cs index a91be72a..79d02552 100644 --- a/src/Generated/Models/FileSearchToolDefinition.cs +++ b/src/Generated/Models/FileSearchToolDefinition.cs @@ -5,13 +5,12 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FileSearchToolDefinition : ToolDefinition { - public partial class FileSearchToolDefinition : ToolDefinition + internal FileSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalAssistantToolsFileSearchFileSearch fileSearch) : base(type, serializedAdditionalRawData) { - internal FileSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalAssistantToolsFileSearchFileSearch fileSearch) : base(type, serializedAdditionalRawData) - { - _fileSearch = fileSearch; - } + _fileSearch = fileSearch; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FileSearchToolResources.Serialization.cs b/src/Generated/Models/FileSearchToolResources.Serialization.cs index 15df3db9..07beb6c8 100644 --- a/src/Generated/Models/FileSearchToolResources.Serialization.cs +++ b/src/Generated/Models/FileSearchToolResources.Serialization.cs @@ -8,160 +8,159 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FileSearchToolResources : IJsonModel { - public partial class FileSearchToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("vector_store_ids") != true && Optional.IsCollectionDefined(VectorStoreIds)) - { - writer.WritePropertyName("vector_store_ids"u8); - writer.WriteStartArray(); - foreach (var item in VectorStoreIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("vector_stores") != true && Optional.IsCollectionDefined(NewVectorStores)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("vector_store_ids") != true && Optional.IsCollectionDefined(VectorStoreIds)) + { + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (var item in VectorStoreIds) { - writer.WritePropertyName("vector_stores"u8); - SerializeNewVectorStores(writer, options); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("vector_stores") != true && Optional.IsCollectionDefined(NewVectorStores)) + { + writer.WritePropertyName("vector_stores"u8); + SerializeNewVectorStores(writer, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FileSearchToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FileSearchToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileSearchToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support reading '{format}' format."); } - internal static FileSearchToolResources DeserializeFileSearchToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList vectorStoreIds = default; - IList vectorStores = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static FileSearchToolResources DeserializeFileSearchToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList vectorStoreIds = default; + IList vectorStores = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vector_store_ids"u8)) { - if (property.NameEquals("vector_store_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - vectorStoreIds = array; continue; } - if (property.NameEquals("vector_stores"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + vectorStoreIds = array; + continue; + } + if (property.NameEquals("vector_stores"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStoreCreationHelper.DeserializeVectorStoreCreationHelper(item, options)); - } - vectorStores = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(VectorStoreCreationHelper.DeserializeVectorStoreCreationHelper(item, options)); } + vectorStores = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FileSearchToolResources(vectorStoreIds ?? new ChangeTrackingList(), vectorStores ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolResources(vectorStoreIds ?? new ChangeTrackingList(), vectorStores ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - FileSearchToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFileSearchToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + FileSearchToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FileSearchToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFileSearchToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileSearchToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FileSearchToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileSearchToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FileSearchToolResources.cs b/src/Generated/Models/FileSearchToolResources.cs index 21ddbd78..35561ee0 100644 --- a/src/Generated/Models/FileSearchToolResources.cs +++ b/src/Generated/Models/FileSearchToolResources.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FileSearchToolResources { - public partial class FileSearchToolResources - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal FileSearchToolResources(IList vectorStoreIds, IList newVectorStores, IDictionary serializedAdditionalRawData) - { - VectorStoreIds = vectorStoreIds; - NewVectorStores = newVectorStores; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal FileSearchToolResources(IList vectorStoreIds, IList newVectorStores, IDictionary serializedAdditionalRawData) + { + VectorStoreIds = vectorStoreIds; + NewVectorStores = newVectorStores; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FileUploadPurpose.cs b/src/Generated/Models/FileUploadPurpose.cs index 9c08633a..f9029f73 100644 --- a/src/Generated/Models/FileUploadPurpose.cs +++ b/src/Generated/Models/FileUploadPurpose.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +public readonly partial struct FileUploadPurpose : IEquatable { - public readonly partial struct FileUploadPurpose : IEquatable + private readonly string _value; + + public FileUploadPurpose(string value) { - private readonly string _value; - - public FileUploadPurpose(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AssistantsValue = "assistants"; - private const string BatchValue = "batch"; - private const string FineTuneValue = "fine-tune"; - private const string VisionValue = "vision"; - - public static FileUploadPurpose Assistants { get; } = new FileUploadPurpose(AssistantsValue); - public static FileUploadPurpose Batch { get; } = new FileUploadPurpose(BatchValue); - public static FileUploadPurpose FineTune { get; } = new FileUploadPurpose(FineTuneValue); - public static FileUploadPurpose Vision { get; } = new FileUploadPurpose(VisionValue); - public static bool operator ==(FileUploadPurpose left, FileUploadPurpose right) => left.Equals(right); - public static bool operator !=(FileUploadPurpose left, FileUploadPurpose right) => !left.Equals(right); - public static implicit operator FileUploadPurpose(string value) => new FileUploadPurpose(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FileUploadPurpose other && Equals(other); - public bool Equals(FileUploadPurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AssistantsValue = "assistants"; + private const string BatchValue = "batch"; + private const string FineTuneValue = "fine-tune"; + private const string VisionValue = "vision"; + + public static FileUploadPurpose Assistants { get; } = new FileUploadPurpose(AssistantsValue); + public static FileUploadPurpose Batch { get; } = new FileUploadPurpose(BatchValue); + public static FileUploadPurpose FineTune { get; } = new FileUploadPurpose(FineTuneValue); + public static FileUploadPurpose Vision { get; } = new FileUploadPurpose(VisionValue); + public static bool operator ==(FileUploadPurpose left, FileUploadPurpose right) => left.Equals(right); + public static bool operator !=(FileUploadPurpose left, FileUploadPurpose right) => !left.Equals(right); + public static implicit operator FileUploadPurpose(string value) => new FileUploadPurpose(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileUploadPurpose other && Equals(other); + public bool Equals(FileUploadPurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningIntegration.Serialization.cs b/src/Generated/Models/FineTuningIntegration.Serialization.cs index c2f16095..e611f8c0 100644 --- a/src/Generated/Models/FineTuningIntegration.Serialization.cs +++ b/src/Generated/Models/FineTuningIntegration.Serialization.cs @@ -7,117 +7,116 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +[PersistableModelProxy(typeof(UnknownCreateFineTuningJobRequestIntegration))] +internal partial class FineTuningIntegration : IJsonModel { - [PersistableModelProxy(typeof(UnknownCreateFineTuningJobRequestIntegration))] - internal partial class FineTuningIntegration : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningIntegration(document.RootElement, options); + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{format}' format."); } - internal static FineTuningIntegration DeserializeFineTuningIntegration(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningIntegration(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "wandb": return WeightsAndBiasesIntegration.DeserializeWeightsAndBiasesIntegration(element, options); - } - } - return UnknownCreateFineTuningJobRequestIntegration.DeserializeUnknownCreateFineTuningJobRequestIntegration(element, options); - } + internal static FineTuningIntegration DeserializeFineTuningIntegration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{options.Format}' format."); - } + return null; } - - FineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningIntegration(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{options.Format}' format."); + case "wandb": return WeightsAndBiasesIntegration.DeserializeWeightsAndBiasesIntegration(element, options); } } + return UnknownCreateFineTuningJobRequestIntegration.DeserializeUnknownCreateFineTuningJobRequestIntegration(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FineTuningIntegration FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFineTuningIntegration(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + FineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningIntegration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FineTuningIntegration FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFineTuningIntegration(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningIntegration.cs b/src/Generated/Models/FineTuningIntegration.cs index 53daa38c..780c9d58 100644 --- a/src/Generated/Models/FineTuningIntegration.cs +++ b/src/Generated/Models/FineTuningIntegration.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal abstract partial class FineTuningIntegration { - internal abstract partial class FineTuningIntegration + internal IDictionary SerializedAdditionalRawData { get; set; } + protected FineTuningIntegration() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected FineTuningIntegration() - { - } - - internal FineTuningIntegration(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal FineTuningIntegration(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningIntegrationWandbWandb.Serialization.cs b/src/Generated/Models/FineTuningIntegrationWandbWandb.Serialization.cs index dea000f0..6aabc20a 100644 --- a/src/Generated/Models/FineTuningIntegrationWandbWandb.Serialization.cs +++ b/src/Generated/Models/FineTuningIntegrationWandbWandb.Serialization.cs @@ -8,197 +8,196 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningIntegrationWandbWandb : IJsonModel { - internal partial class FineTuningIntegrationWandbWandb : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("project") != true) + { + writer.WritePropertyName("project"u8); + writer.WriteStringValue(Project); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + if (Name != null) { - throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support writing '{format}' format."); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("project") != true) + else { - writer.WritePropertyName("project"u8); - writer.WriteStringValue(Project); + writer.WriteNull("name"); } - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + } + if (SerializedAdditionalRawData?.ContainsKey("entity") != true && Optional.IsDefined(Entity)) + { + if (Entity != null) { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } + writer.WritePropertyName("entity"u8); + writer.WriteStringValue(Entity); } - if (SerializedAdditionalRawData?.ContainsKey("entity") != true && Optional.IsDefined(Entity)) + else { - if (Entity != null) - { - writer.WritePropertyName("entity"u8); - writer.WriteStringValue(Entity); - } - else - { - writer.WriteNull("entity"); - } + writer.WriteNull("entity"); } - if (SerializedAdditionalRawData?.ContainsKey("tags") != true && Optional.IsCollectionDefined(Tags)) + } + if (SerializedAdditionalRawData?.ContainsKey("tags") != true && Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartArray(); + foreach (var item in Tags) { - writer.WritePropertyName("tags"u8); - writer.WriteStartArray(); - foreach (var item in Tags) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FineTuningIntegrationWandbWandb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FineTuningIntegrationWandbWandb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningIntegrationWandbWandb(document.RootElement, options); + throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support reading '{format}' format."); } - internal static FineTuningIntegrationWandbWandb DeserializeFineTuningIntegrationWandbWandb(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningIntegrationWandbWandb(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static FineTuningIntegrationWandbWandb DeserializeFineTuningIntegrationWandbWandb(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string project = default; + string name = default; + string entity = default; + IReadOnlyList tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("project"u8)) { - return null; + project = property.Value.GetString(); + continue; } - string project = default; - string name = default; - string entity = default; - IReadOnlyList tags = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("project"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - project = property.Value.GetString(); + name = null; continue; } - if (property.NameEquals("name"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("entity"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("entity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - entity = null; - continue; - } - entity = property.Value.GetString(); + entity = null; continue; } - if (property.NameEquals("tags"u8)) + entity = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - tags = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + tags = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FineTuningIntegrationWandbWandb(project, name, entity, tags ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FineTuningIntegrationWandbWandb(project, name, entity, tags ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - FineTuningIntegrationWandbWandb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningIntegrationWandbWandb(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + FineTuningIntegrationWandbWandb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FineTuningIntegrationWandbWandb FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFineTuningIntegrationWandbWandb(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningIntegrationWandbWandb(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningIntegrationWandbWandb)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FineTuningIntegrationWandbWandb FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFineTuningIntegrationWandbWandb(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningIntegrationWandbWandb.cs b/src/Generated/Models/FineTuningIntegrationWandbWandb.cs index 6be0538b..2dfeb445 100644 --- a/src/Generated/Models/FineTuningIntegrationWandbWandb.cs +++ b/src/Generated/Models/FineTuningIntegrationWandbWandb.cs @@ -5,35 +5,34 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningIntegrationWandbWandb { - internal partial class FineTuningIntegrationWandbWandb + internal IDictionary SerializedAdditionalRawData { get; set; } + internal FineTuningIntegrationWandbWandb(string project) + { + Argument.AssertNotNull(project, nameof(project)); + + Project = project; + Tags = new ChangeTrackingList(); + } + + internal FineTuningIntegrationWandbWandb(string project, string name, string entity, IReadOnlyList tags, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal FineTuningIntegrationWandbWandb(string project) - { - Argument.AssertNotNull(project, nameof(project)); - - Project = project; - Tags = new ChangeTrackingList(); - } - - internal FineTuningIntegrationWandbWandb(string project, string name, string entity, IReadOnlyList tags, IDictionary serializedAdditionalRawData) - { - Project = project; - Name = name; - Entity = entity; - Tags = tags; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal FineTuningIntegrationWandbWandb() - { - } - - public string Project { get; } - public string Name { get; } - public string Entity { get; } - public IReadOnlyList Tags { get; } + Project = project; + Name = name; + Entity = entity; + Tags = tags; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal FineTuningIntegrationWandbWandb() + { + } + + public string Project { get; } + public string Name { get; } + public string Entity { get; } + public IReadOnlyList Tags { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJob.Serialization.cs b/src/Generated/Models/FineTuningJob.Serialization.cs index 4a633976..757dda6b 100644 --- a/src/Generated/Models/FineTuningJob.Serialization.cs +++ b/src/Generated/Models/FineTuningJob.Serialization.cs @@ -8,447 +8,446 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningJob : IJsonModel { - internal partial class FineTuningJob : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJob)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FineTuningJob)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("user_provided_suffix") != true && Optional.IsDefined(UserProvidedSuffix)) - { - if (UserProvidedSuffix != null) - { - writer.WritePropertyName("user_provided_suffix"u8); - writer.WriteStringValue(UserProvidedSuffix); - } - else - { - writer.WriteNull("user_provided_suffix"); - } - } - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("user_provided_suffix") != true && Optional.IsDefined(UserProvidedSuffix)) + { + if (UserProvidedSuffix != null) { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WritePropertyName("user_provided_suffix"u8); + writer.WriteStringValue(UserProvidedSuffix); } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + else { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WriteNull("user_provided_suffix"); } - if (SerializedAdditionalRawData?.ContainsKey("error") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("error") != true) + { + if (Error != null) { - if (Error != null) - { - writer.WritePropertyName("error"u8); - writer.WriteObjectValue(Error, options); - } - else - { - writer.WriteNull("error"); - } + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); } - if (SerializedAdditionalRawData?.ContainsKey("fine_tuned_model") != true) + else { - if (FineTunedModel != null) - { - writer.WritePropertyName("fine_tuned_model"u8); - writer.WriteStringValue(FineTunedModel); - } - else - { - writer.WriteNull("fine_tuned_model"); - } + writer.WriteNull("error"); } - if (SerializedAdditionalRawData?.ContainsKey("finished_at") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("fine_tuned_model") != true) + { + if (FineTunedModel != null) { - if (FinishedAt != null) - { - writer.WritePropertyName("finished_at"u8); - writer.WriteNumberValue(FinishedAt.Value, "U"); - } - else - { - writer.WriteNull("finished_at"); - } + writer.WritePropertyName("fine_tuned_model"u8); + writer.WriteStringValue(FineTunedModel); } - if (SerializedAdditionalRawData?.ContainsKey("hyperparameters") != true) + else { - writer.WritePropertyName("hyperparameters"u8); - writer.WriteObjectValue(Hyperparameters, options); + writer.WriteNull("fine_tuned_model"); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("finished_at") != true) + { + if (FinishedAt != null) { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); + writer.WritePropertyName("finished_at"u8); + writer.WriteNumberValue(FinishedAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + else { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteNull("finished_at"); } - if (SerializedAdditionalRawData?.ContainsKey("organization_id") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("hyperparameters") != true) + { + writer.WritePropertyName("hyperparameters"u8); + writer.WriteObjectValue(Hyperparameters, options); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("organization_id") != true) + { + writer.WritePropertyName("organization_id"u8); + writer.WriteStringValue(OrganizationId); + } + if (SerializedAdditionalRawData?.ContainsKey("result_files") != true) + { + writer.WritePropertyName("result_files"u8); + writer.WriteStartArray(); + foreach (var item in ResultFiles) { - writer.WritePropertyName("organization_id"u8); - writer.WriteStringValue(OrganizationId); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData?.ContainsKey("result_files") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("trained_tokens") != true) + { + if (TrainedTokens != null) { - writer.WritePropertyName("result_files"u8); - writer.WriteStartArray(); - foreach (var item in ResultFiles) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WritePropertyName("trained_tokens"u8); + writer.WriteNumberValue(TrainedTokens.Value); } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + else { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); + writer.WriteNull("trained_tokens"); } - if (SerializedAdditionalRawData?.ContainsKey("trained_tokens") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("training_file") != true) + { + writer.WritePropertyName("training_file"u8); + writer.WriteStringValue(TrainingFile); + } + if (SerializedAdditionalRawData?.ContainsKey("validation_file") != true) + { + if (ValidationFile != null) { - if (TrainedTokens != null) - { - writer.WritePropertyName("trained_tokens"u8); - writer.WriteNumberValue(TrainedTokens.Value); - } - else - { - writer.WriteNull("trained_tokens"); - } + writer.WritePropertyName("validation_file"u8); + writer.WriteStringValue(ValidationFile); } - if (SerializedAdditionalRawData?.ContainsKey("training_file") != true) + else { - writer.WritePropertyName("training_file"u8); - writer.WriteStringValue(TrainingFile); + writer.WriteNull("validation_file"); } - if (SerializedAdditionalRawData?.ContainsKey("validation_file") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("integrations") != true && Optional.IsCollectionDefined(Integrations)) + { + if (Integrations != null) { - if (ValidationFile != null) - { - writer.WritePropertyName("validation_file"u8); - writer.WriteStringValue(ValidationFile); - } - else + writer.WritePropertyName("integrations"u8); + writer.WriteStartArray(); + foreach (var item in Integrations) { - writer.WriteNull("validation_file"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("integrations") != true && Optional.IsCollectionDefined(Integrations)) + else { - if (Integrations != null) - { - writer.WritePropertyName("integrations"u8); - writer.WriteStartArray(); - foreach (var item in Integrations) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("integrations"); - } + writer.WriteNull("integrations"); } - if (SerializedAdditionalRawData?.ContainsKey("seed") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("seed") != true) + { + writer.WritePropertyName("seed"u8); + writer.WriteNumberValue(Seed); + } + if (SerializedAdditionalRawData?.ContainsKey("estimated_finish") != true && Optional.IsDefined(EstimatedFinish)) + { + if (EstimatedFinish != null) { - writer.WritePropertyName("seed"u8); - writer.WriteNumberValue(Seed); + writer.WritePropertyName("estimated_finish"u8); + writer.WriteNumberValue(EstimatedFinish.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("estimated_finish") != true && Optional.IsDefined(EstimatedFinish)) + else { - if (EstimatedFinish != null) - { - writer.WritePropertyName("estimated_finish"u8); - writer.WriteNumberValue(EstimatedFinish.Value, "U"); - } - else - { - writer.WriteNull("estimated_finish"); - } + writer.WriteNull("estimated_finish"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FineTuningJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FineTuningJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJob)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningJob(document.RootElement, options); + throw new FormatException($"The model {nameof(FineTuningJob)} does not support reading '{format}' format."); } - internal static FineTuningJob DeserializeFineTuningJob(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningJob(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string userProvidedSuffix = default; - string id = default; - DateTimeOffset createdAt = default; - FineTuningJobError error = default; - string fineTunedModel = default; - DateTimeOffset? finishedAt = default; - FineTuningJobHyperparameters hyperparameters = default; - string model = default; - InternalFineTuningJobObject @object = default; - string organizationId = default; - IReadOnlyList resultFiles = default; - FineTuningJobStatus status = default; - int? trainedTokens = default; - string trainingFile = default; - string validationFile = default; - IReadOnlyList integrations = default; - int seed = default; - DateTimeOffset? estimatedFinish = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("user_provided_suffix"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - userProvidedSuffix = null; - continue; - } - userProvidedSuffix = property.Value.GetString(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("error"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - error = null; - continue; - } - error = FineTuningJobError.DeserializeFineTuningJobError(property.Value, options); - continue; - } - if (property.NameEquals("fine_tuned_model"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - fineTunedModel = null; - continue; - } - fineTunedModel = property.Value.GetString(); - continue; - } - if (property.NameEquals("finished_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - finishedAt = null; - continue; - } - finishedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("hyperparameters"u8)) - { - hyperparameters = FineTuningJobHyperparameters.DeserializeFineTuningJobHyperparameters(property.Value, options); - continue; - } - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) + internal static FineTuningJob DeserializeFineTuningJob(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string userProvidedSuffix = default; + string id = default; + DateTimeOffset createdAt = default; + FineTuningJobError error = default; + string fineTunedModel = default; + DateTimeOffset? finishedAt = default; + FineTuningJobHyperparameters hyperparameters = default; + string model = default; + InternalFineTuningJobObject @object = default; + string organizationId = default; + IReadOnlyList resultFiles = default; + FineTuningJobStatus status = default; + int? trainedTokens = default; + string trainingFile = default; + string validationFile = default; + IReadOnlyList integrations = default; + int seed = default; + DateTimeOffset? estimatedFinish = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("user_provided_suffix"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - @object = new InternalFineTuningJobObject(property.Value.GetString()); + userProvidedSuffix = null; continue; } - if (property.NameEquals("organization_id"u8)) + userProvidedSuffix = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - organizationId = property.Value.GetString(); + error = null; continue; } - if (property.NameEquals("result_files"u8)) + error = FineTuningJobError.DeserializeFineTuningJobError(property.Value, options); + continue; + } + if (property.NameEquals("fine_tuned_model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - resultFiles = array; + fineTunedModel = null; continue; } - if (property.NameEquals("status"u8)) + fineTunedModel = property.Value.GetString(); + continue; + } + if (property.NameEquals("finished_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - status = new FineTuningJobStatus(property.Value.GetString()); + finishedAt = null; continue; } - if (property.NameEquals("trained_tokens"u8)) + finishedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("hyperparameters"u8)) + { + hyperparameters = FineTuningJobHyperparameters.DeserializeFineTuningJobHyperparameters(property.Value, options); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalFineTuningJobObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("organization_id"u8)) + { + organizationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("result_files"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - trainedTokens = null; - continue; - } - trainedTokens = property.Value.GetInt32(); - continue; + array.Add(item.GetString()); } - if (property.NameEquals("training_file"u8)) + resultFiles = array; + continue; + } + if (property.NameEquals("status"u8)) + { + status = new FineTuningJobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("trained_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - trainingFile = property.Value.GetString(); + trainedTokens = null; continue; } - if (property.NameEquals("validation_file"u8)) + trainedTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("training_file"u8)) + { + trainingFile = property.Value.GetString(); + continue; + } + if (property.NameEquals("validation_file"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - validationFile = null; - continue; - } - validationFile = property.Value.GetString(); + validationFile = null; continue; } - if (property.NameEquals("integrations"u8)) + validationFile = property.Value.GetString(); + continue; + } + if (property.NameEquals("integrations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalFineTuningIntegration.DeserializeInternalFineTuningIntegration(item, options)); - } - integrations = array; continue; } - if (property.NameEquals("seed"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - seed = property.Value.GetInt32(); - continue; + array.Add(InternalFineTuningIntegration.DeserializeInternalFineTuningIntegration(item, options)); } - if (property.NameEquals("estimated_finish"u8)) + integrations = array; + continue; + } + if (property.NameEquals("seed"u8)) + { + seed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("estimated_finish"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - estimatedFinish = null; - continue; - } - estimatedFinish = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + estimatedFinish = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + estimatedFinish = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FineTuningJob( - userProvidedSuffix, - id, - createdAt, - error, - fineTunedModel, - finishedAt, - hyperparameters, - model, - @object, - organizationId, - resultFiles, - status, - trainedTokens, - trainingFile, - validationFile, - integrations ?? new ChangeTrackingList(), - seed, - estimatedFinish, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningJob)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FineTuningJob( + userProvidedSuffix, + id, + createdAt, + error, + fineTunedModel, + finishedAt, + hyperparameters, + model, + @object, + organizationId, + resultFiles, + status, + trainedTokens, + trainingFile, + validationFile, + integrations ?? new ChangeTrackingList(), + seed, + estimatedFinish, + serializedAdditionalRawData); + } - FineTuningJob IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningJob(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningJob)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningJob)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + FineTuningJob IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FineTuningJob FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFineTuningJob(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningJob(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningJob)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FineTuningJob FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFineTuningJob(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJob.cs b/src/Generated/Models/FineTuningJob.cs index fc955ef7..a259ef58 100644 --- a/src/Generated/Models/FineTuningJob.cs +++ b/src/Generated/Models/FineTuningJob.cs @@ -6,81 +6,80 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningJob { - internal partial class FineTuningJob + internal IDictionary SerializedAdditionalRawData { get; set; } + internal FineTuningJob(string id, DateTimeOffset createdAt, FineTuningJobError error, string fineTunedModel, DateTimeOffset? finishedAt, FineTuningJobHyperparameters hyperparameters, string model, string organizationId, IEnumerable resultFiles, FineTuningJobStatus status, int? trainedTokens, string trainingFile, string validationFile, int seed) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal FineTuningJob(string id, DateTimeOffset createdAt, FineTuningJobError error, string fineTunedModel, DateTimeOffset? finishedAt, FineTuningJobHyperparameters hyperparameters, string model, string organizationId, IEnumerable resultFiles, FineTuningJobStatus status, int? trainedTokens, string trainingFile, string validationFile, int seed) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(model, nameof(model)); - Argument.AssertNotNull(organizationId, nameof(organizationId)); - Argument.AssertNotNull(resultFiles, nameof(resultFiles)); - Argument.AssertNotNull(trainingFile, nameof(trainingFile)); + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(model, nameof(model)); + Argument.AssertNotNull(organizationId, nameof(organizationId)); + Argument.AssertNotNull(resultFiles, nameof(resultFiles)); + Argument.AssertNotNull(trainingFile, nameof(trainingFile)); - Id = id; - CreatedAt = createdAt; - Error = error; - FineTunedModel = fineTunedModel; - FinishedAt = finishedAt; - Hyperparameters = hyperparameters; - Model = model; - OrganizationId = organizationId; - ResultFiles = resultFiles.ToList(); - Status = status; - TrainedTokens = trainedTokens; - TrainingFile = trainingFile; - ValidationFile = validationFile; - Integrations = new ChangeTrackingList(); - Seed = seed; - } + Id = id; + CreatedAt = createdAt; + Error = error; + FineTunedModel = fineTunedModel; + FinishedAt = finishedAt; + Hyperparameters = hyperparameters; + Model = model; + OrganizationId = organizationId; + ResultFiles = resultFiles.ToList(); + Status = status; + TrainedTokens = trainedTokens; + TrainingFile = trainingFile; + ValidationFile = validationFile; + Integrations = new ChangeTrackingList(); + Seed = seed; + } - internal FineTuningJob(string userProvidedSuffix, string id, DateTimeOffset createdAt, FineTuningJobError error, string fineTunedModel, DateTimeOffset? finishedAt, FineTuningJobHyperparameters hyperparameters, string model, InternalFineTuningJobObject @object, string organizationId, IReadOnlyList resultFiles, FineTuningJobStatus status, int? trainedTokens, string trainingFile, string validationFile, IReadOnlyList integrations, int seed, DateTimeOffset? estimatedFinish, IDictionary serializedAdditionalRawData) - { - UserProvidedSuffix = userProvidedSuffix; - Id = id; - CreatedAt = createdAt; - Error = error; - FineTunedModel = fineTunedModel; - FinishedAt = finishedAt; - Hyperparameters = hyperparameters; - Model = model; - Object = @object; - OrganizationId = organizationId; - ResultFiles = resultFiles; - Status = status; - TrainedTokens = trainedTokens; - TrainingFile = trainingFile; - ValidationFile = validationFile; - Integrations = integrations; - Seed = seed; - EstimatedFinish = estimatedFinish; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal FineTuningJob(string userProvidedSuffix, string id, DateTimeOffset createdAt, FineTuningJobError error, string fineTunedModel, DateTimeOffset? finishedAt, FineTuningJobHyperparameters hyperparameters, string model, InternalFineTuningJobObject @object, string organizationId, IReadOnlyList resultFiles, FineTuningJobStatus status, int? trainedTokens, string trainingFile, string validationFile, IReadOnlyList integrations, int seed, DateTimeOffset? estimatedFinish, IDictionary serializedAdditionalRawData) + { + UserProvidedSuffix = userProvidedSuffix; + Id = id; + CreatedAt = createdAt; + Error = error; + FineTunedModel = fineTunedModel; + FinishedAt = finishedAt; + Hyperparameters = hyperparameters; + Model = model; + Object = @object; + OrganizationId = organizationId; + ResultFiles = resultFiles; + Status = status; + TrainedTokens = trainedTokens; + TrainingFile = trainingFile; + ValidationFile = validationFile; + Integrations = integrations; + Seed = seed; + EstimatedFinish = estimatedFinish; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal FineTuningJob() - { - } + internal FineTuningJob() + { + } - public string UserProvidedSuffix { get; } - public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public FineTuningJobError Error { get; } - public string FineTunedModel { get; } - public DateTimeOffset? FinishedAt { get; } - public FineTuningJobHyperparameters Hyperparameters { get; } - public string Model { get; } - public InternalFineTuningJobObject Object { get; } = InternalFineTuningJobObject.FineTuningJob; + public string UserProvidedSuffix { get; } + public string Id { get; } + public DateTimeOffset CreatedAt { get; } + public FineTuningJobError Error { get; } + public string FineTunedModel { get; } + public DateTimeOffset? FinishedAt { get; } + public FineTuningJobHyperparameters Hyperparameters { get; } + public string Model { get; } + public InternalFineTuningJobObject Object { get; } = InternalFineTuningJobObject.FineTuningJob; - public string OrganizationId { get; } - public IReadOnlyList ResultFiles { get; } - public FineTuningJobStatus Status { get; } - public int? TrainedTokens { get; } - public string TrainingFile { get; } - public string ValidationFile { get; } - public IReadOnlyList Integrations { get; } - public int Seed { get; } - public DateTimeOffset? EstimatedFinish { get; } - } -} + public string OrganizationId { get; } + public IReadOnlyList ResultFiles { get; } + public FineTuningJobStatus Status { get; } + public int? TrainedTokens { get; } + public string TrainingFile { get; } + public string ValidationFile { get; } + public IReadOnlyList Integrations { get; } + public int Seed { get; } + public DateTimeOffset? EstimatedFinish { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobError.Serialization.cs b/src/Generated/Models/FineTuningJobError.Serialization.cs index 67b61856..c434f95f 100644 --- a/src/Generated/Models/FineTuningJobError.Serialization.cs +++ b/src/Generated/Models/FineTuningJobError.Serialization.cs @@ -8,160 +8,159 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningJobError : IJsonModel { - internal partial class FineTuningJobError : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJobError)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FineTuningJobError)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code") != true) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData?.ContainsKey("param") != true) + { + if (Param != null) { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code); + writer.WritePropertyName("param"u8); + writer.WriteStringValue(Param); } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) + else { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); + writer.WriteNull("param"); } - if (SerializedAdditionalRawData?.ContainsKey("param") != true) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Param != null) - { - writer.WritePropertyName("param"u8); - writer.WriteStringValue(Param); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("param"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FineTuningJobError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FineTuningJobError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJobError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningJobError(document.RootElement, options); + throw new FormatException($"The model {nameof(FineTuningJobError)} does not support reading '{format}' format."); } - internal static FineTuningJobError DeserializeFineTuningJobError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningJobError(document.RootElement, options); + } + + internal static FineTuningJobError DeserializeFineTuningJobError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + string param = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) { - return null; + code = property.Value.GetString(); + continue; } - string code = default; - string message = default; - string param = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("message"u8)) { - if (property.NameEquals("code"u8)) - { - code = property.Value.GetString(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (property.NameEquals("param"u8)) + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("param"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - param = null; - continue; - } - param = property.Value.GetString(); + param = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + param = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FineTuningJobError(code, message, param, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningJobError)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FineTuningJobError(code, message, param, serializedAdditionalRawData); + } - FineTuningJobError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningJobError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningJobError)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningJobError)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + FineTuningJobError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FineTuningJobError FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFineTuningJobError(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningJobError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningJobError)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FineTuningJobError FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFineTuningJobError(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobError.cs b/src/Generated/Models/FineTuningJobError.cs index dbd6f410..1651aef4 100644 --- a/src/Generated/Models/FineTuningJobError.cs +++ b/src/Generated/Models/FineTuningJobError.cs @@ -5,35 +5,34 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningJobError { - internal partial class FineTuningJobError + internal IDictionary SerializedAdditionalRawData { get; set; } + internal FineTuningJobError(string code, string message, string param) + { + Argument.AssertNotNull(code, nameof(code)); + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + Param = param; + } + + internal FineTuningJobError(string code, string message, string param, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal FineTuningJobError(string code, string message, string param) - { - Argument.AssertNotNull(code, nameof(code)); - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - Param = param; - } - - internal FineTuningJobError(string code, string message, string param, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - Param = param; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal FineTuningJobError() - { - } - - public string Code { get; } - public string Message { get; } - public string Param { get; } + Code = code; + Message = message; + Param = param; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal FineTuningJobError() + { + } + + public string Code { get; } + public string Message { get; } + public string Param { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobEvent.Serialization.cs b/src/Generated/Models/FineTuningJobEvent.Serialization.cs index d03b6f08..26f44e08 100644 --- a/src/Generated/Models/FineTuningJobEvent.Serialization.cs +++ b/src/Generated/Models/FineTuningJobEvent.Serialization.cs @@ -8,176 +8,175 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningJobEvent : IJsonModel { - internal partial class FineTuningJobEvent : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) - { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("level") != true) - { - writer.WritePropertyName("level"u8); - writer.WriteStringValue(Level.ToSerialString()); - } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) - { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("level") != true) + { + writer.WritePropertyName("level"u8); + writer.WriteStringValue(Level.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FineTuningJobEvent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FineTuningJobEvent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningJobEvent(document.RootElement, options); + throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support reading '{format}' format."); } - internal static FineTuningJobEvent DeserializeFineTuningJobEvent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningJobEvent(document.RootElement, options); + } + + internal static FineTuningJobEvent DeserializeFineTuningJobEvent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + DateTimeOffset createdAt = default; + FineTuningJobEventLevel level = default; + string message = default; + InternalFineTuningJobEventObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - DateTimeOffset createdAt = default; - FineTuningJobEventLevel level = default; - string message = default; - InternalFineTuningJobEventObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("created_at"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("level"u8)) - { - level = property.Value.GetString().ToFineTuningJobEventLevel(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalFineTuningJobEventObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FineTuningJobEvent( - id, - createdAt, - level, - message, - @object, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("level"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support writing '{options.Format}' format."); + level = property.Value.GetString().ToFineTuningJobEventLevel(); + continue; } - } - - FineTuningJobEvent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("message"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningJobEvent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support reading '{options.Format}' format."); + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalFineTuningJobEventObject(property.Value.GetString()); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FineTuningJobEvent( + id, + createdAt, + level, + message, + @object, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FineTuningJobEvent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFineTuningJobEvent(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + FineTuningJobEvent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningJobEvent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningJobEvent)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FineTuningJobEvent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFineTuningJobEvent(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobEvent.cs b/src/Generated/Models/FineTuningJobEvent.cs index 5b169027..af9153ce 100644 --- a/src/Generated/Models/FineTuningJobEvent.cs +++ b/src/Generated/Models/FineTuningJobEvent.cs @@ -5,40 +5,39 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningJobEvent { - internal partial class FineTuningJobEvent + internal IDictionary SerializedAdditionalRawData { get; set; } + internal FineTuningJobEvent(string id, DateTimeOffset createdAt, FineTuningJobEventLevel level, string message) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(message, nameof(message)); + + Id = id; + CreatedAt = createdAt; + Level = level; + Message = message; + } + + internal FineTuningJobEvent(string id, DateTimeOffset createdAt, FineTuningJobEventLevel level, string message, InternalFineTuningJobEventObject @object, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal FineTuningJobEvent(string id, DateTimeOffset createdAt, FineTuningJobEventLevel level, string message) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(message, nameof(message)); - - Id = id; - CreatedAt = createdAt; - Level = level; - Message = message; - } - - internal FineTuningJobEvent(string id, DateTimeOffset createdAt, FineTuningJobEventLevel level, string message, InternalFineTuningJobEventObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - CreatedAt = createdAt; - Level = level; - Message = message; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal FineTuningJobEvent() - { - } - - public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public FineTuningJobEventLevel Level { get; } - public string Message { get; } - public InternalFineTuningJobEventObject Object { get; } = InternalFineTuningJobEventObject.FineTuningJobEvent; + Id = id; + CreatedAt = createdAt; + Level = level; + Message = message; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal FineTuningJobEvent() + { + } + + public string Id { get; } + public DateTimeOffset CreatedAt { get; } + public FineTuningJobEventLevel Level { get; } + public string Message { get; } + public InternalFineTuningJobEventObject Object { get; } = InternalFineTuningJobEventObject.FineTuningJobEvent; +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobEventLevel.Serialization.cs b/src/Generated/Models/FineTuningJobEventLevel.Serialization.cs index e827bcb6..8d734ad0 100644 --- a/src/Generated/Models/FineTuningJobEventLevel.Serialization.cs +++ b/src/Generated/Models/FineTuningJobEventLevel.Serialization.cs @@ -4,24 +4,23 @@ using System; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal static partial class FineTuningJobEventLevelExtensions { - internal static partial class FineTuningJobEventLevelExtensions + public static string ToSerialString(this FineTuningJobEventLevel value) => value switch { - public static string ToSerialString(this FineTuningJobEventLevel value) => value switch - { - FineTuningJobEventLevel.Info => "info", - FineTuningJobEventLevel.Warn => "warn", - FineTuningJobEventLevel.Error => "error", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown FineTuningJobEventLevel value.") - }; + FineTuningJobEventLevel.Info => "info", + FineTuningJobEventLevel.Warn => "warn", + FineTuningJobEventLevel.Error => "error", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown FineTuningJobEventLevel value.") + }; - public static FineTuningJobEventLevel ToFineTuningJobEventLevel(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "info")) return FineTuningJobEventLevel.Info; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "warn")) return FineTuningJobEventLevel.Warn; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "error")) return FineTuningJobEventLevel.Error; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown FineTuningJobEventLevel value."); - } + public static FineTuningJobEventLevel ToFineTuningJobEventLevel(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "info")) return FineTuningJobEventLevel.Info; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "warn")) return FineTuningJobEventLevel.Warn; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "error")) return FineTuningJobEventLevel.Error; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown FineTuningJobEventLevel value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs b/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs index b264c730..49e25afb 100644 --- a/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs +++ b/src/Generated/Models/FineTuningJobHyperparameters.Serialization.cs @@ -8,175 +8,174 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial struct FineTuningJobHyperparameters : IJsonModel, IJsonModel { - internal partial struct FineTuningJobHyperparameters : IJsonModel, IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("n_epochs") != true) - { - writer.WritePropertyName("n_epochs"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("n_epochs") != true) + { + writer.WritePropertyName("n_epochs"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(NEpochs); #else - using (JsonDocument document = JsonDocument.Parse(NEpochs)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("batch_size") != true) + using (JsonDocument document = JsonDocument.Parse(NEpochs)) { - writer.WritePropertyName("batch_size"u8); + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("batch_size") != true) + { + writer.WritePropertyName("batch_size"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(BatchSize); #else - using (JsonDocument document = JsonDocument.Parse(BatchSize)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("learning_rate_multiplier") != true) + using (JsonDocument document = JsonDocument.Parse(BatchSize)) { - writer.WritePropertyName("learning_rate_multiplier"u8); + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("learning_rate_multiplier") != true) + { + writer.WritePropertyName("learning_rate_multiplier"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(LearningRateMultiplier); #else - using (JsonDocument document = JsonDocument.Parse(LearningRateMultiplier)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(LearningRateMultiplier)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FineTuningJobHyperparameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FineTuningJobHyperparameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningJobHyperparameters(document.RootElement, options); + throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support reading '{format}' format."); } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)this).Write(writer, options); + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningJobHyperparameters(document.RootElement, options); + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)this).Write(writer, options); - object IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)this).Create(ref reader, options); + object IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)this).Create(ref reader, options); - internal static FineTuningJobHyperparameters DeserializeFineTuningJobHyperparameters(JsonElement element, ModelReaderWriterOptions options = null) + internal static FineTuningJobHyperparameters DeserializeFineTuningJobHyperparameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + BinaryData nEpochs = default; + BinaryData batchSize = default; + BinaryData learningRateMultiplier = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - options ??= ModelSerializationExtensions.WireOptions; - - BinaryData nEpochs = default; - BinaryData batchSize = default; - BinaryData learningRateMultiplier = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("n_epochs"u8)) { - if (property.NameEquals("n_epochs"u8)) - { - nEpochs = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("batch_size"u8)) - { - batchSize = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("learning_rate_multiplier"u8)) - { - learningRateMultiplier = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + nEpochs = BinaryData.FromString(property.Value.GetRawText()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FineTuningJobHyperparameters(nEpochs, batchSize, learningRateMultiplier, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("batch_size"u8)) + { + batchSize = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("learning_rate_multiplier"u8)) + { + learningRateMultiplier = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FineTuningJobHyperparameters(nEpochs, batchSize, learningRateMultiplier, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - FineTuningJobHyperparameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support writing '{options.Format}' format."); + } + } - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningJobHyperparameters(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support reading '{options.Format}' format."); - } + FineTuningJobHyperparameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningJobHyperparameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningJobHyperparameters)} does not support reading '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ((IPersistableModel)this).Write(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ((IPersistableModel)this).Write(options); - object IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ((IPersistableModel)this).Create(data, options); + object IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ((IPersistableModel)this).Create(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)this).GetFormatFromOptions(options); + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)this).GetFormatFromOptions(options); - internal static FineTuningJobHyperparameters FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFineTuningJobHyperparameters(document.RootElement); - } + internal static FineTuningJobHyperparameters FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFineTuningJobHyperparameters(document.RootElement); + } - internal BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + internal BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobHyperparameters.cs b/src/Generated/Models/FineTuningJobHyperparameters.cs index 747e9947..862be37c 100644 --- a/src/Generated/Models/FineTuningJobHyperparameters.cs +++ b/src/Generated/Models/FineTuningJobHyperparameters.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct FineTuningJobHyperparameters { - internal readonly partial struct FineTuningJobHyperparameters + internal FineTuningJobHyperparameters(BinaryData nEpochs, BinaryData batchSize, BinaryData learningRateMultiplier) { - internal FineTuningJobHyperparameters(BinaryData nEpochs, BinaryData batchSize, BinaryData learningRateMultiplier) - { - Argument.AssertNotNull(nEpochs, nameof(nEpochs)); - Argument.AssertNotNull(batchSize, nameof(batchSize)); - Argument.AssertNotNull(learningRateMultiplier, nameof(learningRateMultiplier)); + Argument.AssertNotNull(nEpochs, nameof(nEpochs)); + Argument.AssertNotNull(batchSize, nameof(batchSize)); + Argument.AssertNotNull(learningRateMultiplier, nameof(learningRateMultiplier)); - NEpochs = nEpochs; - BatchSize = batchSize; - LearningRateMultiplier = learningRateMultiplier; - } + NEpochs = nEpochs; + BatchSize = batchSize; + LearningRateMultiplier = learningRateMultiplier; + } - internal FineTuningJobHyperparameters(BinaryData nEpochs, BinaryData batchSize, BinaryData learningRateMultiplier, IDictionary serializedAdditionalRawData) - { - NEpochs = nEpochs; - BatchSize = batchSize; - LearningRateMultiplier = learningRateMultiplier; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal FineTuningJobHyperparameters(BinaryData nEpochs, BinaryData batchSize, BinaryData learningRateMultiplier, IDictionary serializedAdditionalRawData) + { + NEpochs = nEpochs; + BatchSize = batchSize; + LearningRateMultiplier = learningRateMultiplier; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public FineTuningJobHyperparameters() - { - } + public FineTuningJobHyperparameters() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs b/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs index 1349f467..12f8fb6f 100644 --- a/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs +++ b/src/Generated/Models/FineTuningJobHyperparametersBatchSizeChoiceEnum.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct FineTuningJobHyperparametersBatchSizeChoiceEnum : IEquatable { - internal readonly partial struct FineTuningJobHyperparametersBatchSizeChoiceEnum : IEquatable - { - private readonly string _value; + private readonly string _value; - public FineTuningJobHyperparametersBatchSizeChoiceEnum(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public FineTuningJobHyperparametersBatchSizeChoiceEnum(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; + private const string AutoValue = "auto"; - public static FineTuningJobHyperparametersBatchSizeChoiceEnum Auto { get; } = new FineTuningJobHyperparametersBatchSizeChoiceEnum(AutoValue); - public static bool operator ==(FineTuningJobHyperparametersBatchSizeChoiceEnum left, FineTuningJobHyperparametersBatchSizeChoiceEnum right) => left.Equals(right); - public static bool operator !=(FineTuningJobHyperparametersBatchSizeChoiceEnum left, FineTuningJobHyperparametersBatchSizeChoiceEnum right) => !left.Equals(right); - public static implicit operator FineTuningJobHyperparametersBatchSizeChoiceEnum(string value) => new FineTuningJobHyperparametersBatchSizeChoiceEnum(value); + public static FineTuningJobHyperparametersBatchSizeChoiceEnum Auto { get; } = new FineTuningJobHyperparametersBatchSizeChoiceEnum(AutoValue); + public static bool operator ==(FineTuningJobHyperparametersBatchSizeChoiceEnum left, FineTuningJobHyperparametersBatchSizeChoiceEnum right) => left.Equals(right); + public static bool operator !=(FineTuningJobHyperparametersBatchSizeChoiceEnum left, FineTuningJobHyperparametersBatchSizeChoiceEnum right) => !left.Equals(right); + public static implicit operator FineTuningJobHyperparametersBatchSizeChoiceEnum(string value) => new FineTuningJobHyperparametersBatchSizeChoiceEnum(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FineTuningJobHyperparametersBatchSizeChoiceEnum other && Equals(other); - public bool Equals(FineTuningJobHyperparametersBatchSizeChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FineTuningJobHyperparametersBatchSizeChoiceEnum other && Equals(other); + public bool Equals(FineTuningJobHyperparametersBatchSizeChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs b/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs index 7aa3f46c..07366d65 100644 --- a/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs +++ b/src/Generated/Models/FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum : IEquatable { - internal readonly partial struct FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum : IEquatable - { - private readonly string _value; + private readonly string _value; - public FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; + private const string AutoValue = "auto"; - public static FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum Auto { get; } = new FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(AutoValue); - public static bool operator ==(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum left, FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum right) => left.Equals(right); - public static bool operator !=(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum left, FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum right) => !left.Equals(right); - public static implicit operator FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(string value) => new FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(value); + public static FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum Auto { get; } = new FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(AutoValue); + public static bool operator ==(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum left, FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum right) => left.Equals(right); + public static bool operator !=(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum left, FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum right) => !left.Equals(right); + public static implicit operator FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(string value) => new FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum other && Equals(other); - public bool Equals(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum other && Equals(other); + public bool Equals(FineTuningJobHyperparametersLearningRateMultiplierChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs b/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs index 7ba8e753..9f91bfd7 100644 --- a/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs +++ b/src/Generated/Models/FineTuningJobHyperparametersNEpochsChoiceEnum.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct FineTuningJobHyperparametersNEpochsChoiceEnum : IEquatable { - internal readonly partial struct FineTuningJobHyperparametersNEpochsChoiceEnum : IEquatable - { - private readonly string _value; + private readonly string _value; - public FineTuningJobHyperparametersNEpochsChoiceEnum(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public FineTuningJobHyperparametersNEpochsChoiceEnum(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; + private const string AutoValue = "auto"; - public static FineTuningJobHyperparametersNEpochsChoiceEnum Auto { get; } = new FineTuningJobHyperparametersNEpochsChoiceEnum(AutoValue); - public static bool operator ==(FineTuningJobHyperparametersNEpochsChoiceEnum left, FineTuningJobHyperparametersNEpochsChoiceEnum right) => left.Equals(right); - public static bool operator !=(FineTuningJobHyperparametersNEpochsChoiceEnum left, FineTuningJobHyperparametersNEpochsChoiceEnum right) => !left.Equals(right); - public static implicit operator FineTuningJobHyperparametersNEpochsChoiceEnum(string value) => new FineTuningJobHyperparametersNEpochsChoiceEnum(value); + public static FineTuningJobHyperparametersNEpochsChoiceEnum Auto { get; } = new FineTuningJobHyperparametersNEpochsChoiceEnum(AutoValue); + public static bool operator ==(FineTuningJobHyperparametersNEpochsChoiceEnum left, FineTuningJobHyperparametersNEpochsChoiceEnum right) => left.Equals(right); + public static bool operator !=(FineTuningJobHyperparametersNEpochsChoiceEnum left, FineTuningJobHyperparametersNEpochsChoiceEnum right) => !left.Equals(right); + public static implicit operator FineTuningJobHyperparametersNEpochsChoiceEnum(string value) => new FineTuningJobHyperparametersNEpochsChoiceEnum(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FineTuningJobHyperparametersNEpochsChoiceEnum other && Equals(other); - public bool Equals(FineTuningJobHyperparametersNEpochsChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FineTuningJobHyperparametersNEpochsChoiceEnum other && Equals(other); + public bool Equals(FineTuningJobHyperparametersNEpochsChoiceEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningJobStatus.cs b/src/Generated/Models/FineTuningJobStatus.cs index 0c9e1236..5b42e24d 100644 --- a/src/Generated/Models/FineTuningJobStatus.cs +++ b/src/Generated/Models/FineTuningJobStatus.cs @@ -5,40 +5,39 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct FineTuningJobStatus : IEquatable { - internal readonly partial struct FineTuningJobStatus : IEquatable + private readonly string _value; + + public FineTuningJobStatus(string value) { - private readonly string _value; - - public FineTuningJobStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ValidatingFilesValue = "validating_files"; - private const string QueuedValue = "queued"; - private const string RunningValue = "running"; - private const string SucceededValue = "succeeded"; - private const string FailedValue = "failed"; - private const string CancelledValue = "cancelled"; - - public static FineTuningJobStatus ValidatingFiles { get; } = new FineTuningJobStatus(ValidatingFilesValue); - public static FineTuningJobStatus Queued { get; } = new FineTuningJobStatus(QueuedValue); - public static FineTuningJobStatus Running { get; } = new FineTuningJobStatus(RunningValue); - public static FineTuningJobStatus Succeeded { get; } = new FineTuningJobStatus(SucceededValue); - public static FineTuningJobStatus Failed { get; } = new FineTuningJobStatus(FailedValue); - public static FineTuningJobStatus Cancelled { get; } = new FineTuningJobStatus(CancelledValue); - public static bool operator ==(FineTuningJobStatus left, FineTuningJobStatus right) => left.Equals(right); - public static bool operator !=(FineTuningJobStatus left, FineTuningJobStatus right) => !left.Equals(right); - public static implicit operator FineTuningJobStatus(string value) => new FineTuningJobStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is FineTuningJobStatus other && Equals(other); - public bool Equals(FineTuningJobStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string ValidatingFilesValue = "validating_files"; + private const string QueuedValue = "queued"; + private const string RunningValue = "running"; + private const string SucceededValue = "succeeded"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + + public static FineTuningJobStatus ValidatingFiles { get; } = new FineTuningJobStatus(ValidatingFilesValue); + public static FineTuningJobStatus Queued { get; } = new FineTuningJobStatus(QueuedValue); + public static FineTuningJobStatus Running { get; } = new FineTuningJobStatus(RunningValue); + public static FineTuningJobStatus Succeeded { get; } = new FineTuningJobStatus(SucceededValue); + public static FineTuningJobStatus Failed { get; } = new FineTuningJobStatus(FailedValue); + public static FineTuningJobStatus Cancelled { get; } = new FineTuningJobStatus(CancelledValue); + public static bool operator ==(FineTuningJobStatus left, FineTuningJobStatus right) => left.Equals(right); + public static bool operator !=(FineTuningJobStatus left, FineTuningJobStatus right) => !left.Equals(right); + public static implicit operator FineTuningJobStatus(string value) => new FineTuningJobStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FineTuningJobStatus other && Equals(other); + public bool Equals(FineTuningJobStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningOptions.Serialization.cs b/src/Generated/Models/FineTuningOptions.Serialization.cs index 76726dc2..84d67015 100644 --- a/src/Generated/Models/FineTuningOptions.Serialization.cs +++ b/src/Generated/Models/FineTuningOptions.Serialization.cs @@ -8,261 +8,260 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningOptions : IJsonModel { - internal partial class FineTuningOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FineTuningOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("training_file") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("training_file"u8); + writer.WriteStringValue(TrainingFile); + } + if (SerializedAdditionalRawData?.ContainsKey("hyperparameters") != true && Optional.IsDefined(Hyperparameters)) + { + writer.WritePropertyName("hyperparameters"u8); + writer.WriteObjectValue(Hyperparameters, options); + } + if (SerializedAdditionalRawData?.ContainsKey("suffix") != true && Optional.IsDefined(Suffix)) + { + if (Suffix != null) { - throw new FormatException($"The model {nameof(FineTuningOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("suffix"u8); + writer.WriteStringValue(Suffix); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + else { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.ToString()); + writer.WriteNull("suffix"); } - if (SerializedAdditionalRawData?.ContainsKey("training_file") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("validation_file") != true && Optional.IsDefined(ValidationFile)) + { + if (ValidationFile != null) { - writer.WritePropertyName("training_file"u8); - writer.WriteStringValue(TrainingFile); + writer.WritePropertyName("validation_file"u8); + writer.WriteStringValue(ValidationFile); } - if (SerializedAdditionalRawData?.ContainsKey("hyperparameters") != true && Optional.IsDefined(Hyperparameters)) + else { - writer.WritePropertyName("hyperparameters"u8); - writer.WriteObjectValue(Hyperparameters, options); + writer.WriteNull("validation_file"); } - if (SerializedAdditionalRawData?.ContainsKey("suffix") != true && Optional.IsDefined(Suffix)) + } + if (SerializedAdditionalRawData?.ContainsKey("integrations") != true && Optional.IsCollectionDefined(Integrations)) + { + if (Integrations != null) { - if (Suffix != null) - { - writer.WritePropertyName("suffix"u8); - writer.WriteStringValue(Suffix); - } - else + writer.WritePropertyName("integrations"u8); + writer.WriteStartArray(); + foreach (var item in Integrations) { - writer.WriteNull("suffix"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("validation_file") != true && Optional.IsDefined(ValidationFile)) + else { - if (ValidationFile != null) - { - writer.WritePropertyName("validation_file"u8); - writer.WriteStringValue(ValidationFile); - } - else - { - writer.WriteNull("validation_file"); - } + writer.WriteNull("integrations"); } - if (SerializedAdditionalRawData?.ContainsKey("integrations") != true && Optional.IsCollectionDefined(Integrations)) + } + if (SerializedAdditionalRawData?.ContainsKey("seed") != true && Optional.IsDefined(Seed)) + { + if (Seed != null) { - if (Integrations != null) - { - writer.WritePropertyName("integrations"u8); - writer.WriteStartArray(); - foreach (var item in Integrations) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("integrations"); - } + writer.WritePropertyName("seed"u8); + writer.WriteNumberValue(Seed.Value); } - if (SerializedAdditionalRawData?.ContainsKey("seed") != true && Optional.IsDefined(Seed)) + else { - if (Seed != null) - { - writer.WritePropertyName("seed"u8); - writer.WriteNumberValue(Seed.Value); - } - else - { - writer.WriteNull("seed"); - } + writer.WriteNull("seed"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - FineTuningOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FineTuningOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(FineTuningOptions)} does not support reading '{format}' format."); } - internal static FineTuningOptions DeserializeFineTuningOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningOptions(document.RootElement, options); + } + + internal static FineTuningOptions DeserializeFineTuningOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateFineTuningJobRequestModel model = default; + string trainingFile = default; + HyperparameterOptions hyperparameters = default; + string suffix = default; + string validationFile = default; + IList integrations = default; + int? seed = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) { - return null; + model = new InternalCreateFineTuningJobRequestModel(property.Value.GetString()); + continue; } - InternalCreateFineTuningJobRequestModel model = default; - string trainingFile = default; - HyperparameterOptions hyperparameters = default; - string suffix = default; - string validationFile = default; - IList integrations = default; - int? seed = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("training_file"u8)) { - if (property.NameEquals("model"u8)) - { - model = new InternalCreateFineTuningJobRequestModel(property.Value.GetString()); - continue; - } - if (property.NameEquals("training_file"u8)) + trainingFile = property.Value.GetString(); + continue; + } + if (property.NameEquals("hyperparameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - trainingFile = property.Value.GetString(); continue; } - if (property.NameEquals("hyperparameters"u8)) + hyperparameters = HyperparameterOptions.DeserializeHyperparameterOptions(property.Value, options); + continue; + } + if (property.NameEquals("suffix"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - hyperparameters = HyperparameterOptions.DeserializeHyperparameterOptions(property.Value, options); + suffix = null; continue; } - if (property.NameEquals("suffix"u8)) + suffix = property.Value.GetString(); + continue; + } + if (property.NameEquals("validation_file"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - suffix = null; - continue; - } - suffix = property.Value.GetString(); + validationFile = null; continue; } - if (property.NameEquals("validation_file"u8)) + validationFile = property.Value.GetString(); + continue; + } + if (property.NameEquals("integrations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - validationFile = null; - continue; - } - validationFile = property.Value.GetString(); continue; } - if (property.NameEquals("integrations"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(FineTuningIntegration.DeserializeFineTuningIntegration(item, options)); - } - integrations = array; - continue; + array.Add(FineTuningIntegration.DeserializeFineTuningIntegration(item, options)); } - if (property.NameEquals("seed"u8)) + integrations = array; + continue; + } + if (property.NameEquals("seed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - seed = null; - continue; - } - seed = property.Value.GetInt32(); + seed = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + seed = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FineTuningOptions( - model, - trainingFile, - hyperparameters, - suffix, - validationFile, - integrations ?? new ChangeTrackingList(), - seed, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FineTuningOptions( + model, + trainingFile, + hyperparameters, + suffix, + validationFile, + integrations ?? new ChangeTrackingList(), + seed, + serializedAdditionalRawData); + } - FineTuningOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + FineTuningOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static FineTuningOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFineTuningOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static FineTuningOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFineTuningOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FineTuningOptions.cs b/src/Generated/Models/FineTuningOptions.cs index 0cbb53b8..7e77939f 100644 --- a/src/Generated/Models/FineTuningOptions.cs +++ b/src/Generated/Models/FineTuningOptions.cs @@ -5,42 +5,41 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class FineTuningOptions { - internal partial class FineTuningOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string trainingFile) + { + Argument.AssertNotNull(trainingFile, nameof(trainingFile)); + + Model = model; + TrainingFile = trainingFile; + Integrations = new ChangeTrackingList(); + } + + internal FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string trainingFile, HyperparameterOptions hyperparameters, string suffix, string validationFile, IList integrations, int? seed, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string trainingFile) - { - Argument.AssertNotNull(trainingFile, nameof(trainingFile)); - - Model = model; - TrainingFile = trainingFile; - Integrations = new ChangeTrackingList(); - } - - internal FineTuningOptions(InternalCreateFineTuningJobRequestModel model, string trainingFile, HyperparameterOptions hyperparameters, string suffix, string validationFile, IList integrations, int? seed, IDictionary serializedAdditionalRawData) - { - Model = model; - TrainingFile = trainingFile; - Hyperparameters = hyperparameters; - Suffix = suffix; - ValidationFile = validationFile; - Integrations = integrations; - Seed = seed; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal FineTuningOptions() - { - } - - public InternalCreateFineTuningJobRequestModel Model { get; } - public string TrainingFile { get; } - public HyperparameterOptions Hyperparameters { get; set; } - public string Suffix { get; set; } - public string ValidationFile { get; set; } - public IList Integrations { get; set; } - public int? Seed { get; set; } + Model = model; + TrainingFile = trainingFile; + Hyperparameters = hyperparameters; + Suffix = suffix; + ValidationFile = validationFile; + Integrations = integrations; + Seed = seed; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal FineTuningOptions() + { + } + + public InternalCreateFineTuningJobRequestModel Model { get; } + public string TrainingFile { get; } + public HyperparameterOptions Hyperparameters { get; set; } + public string Suffix { get; set; } + public string ValidationFile { get; set; } + public IList Integrations { get; set; } + public int? Seed { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/FunctionChatMessage.Serialization.cs b/src/Generated/Models/FunctionChatMessage.Serialization.cs index 398f7d5c..e01deb28 100644 --- a/src/Generated/Models/FunctionChatMessage.Serialization.cs +++ b/src/Generated/Models/FunctionChatMessage.Serialization.cs @@ -8,102 +8,101 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class FunctionChatMessage : IJsonModel { - public partial class FunctionChatMessage : IJsonModel + FunctionChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - FunctionChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FunctionChatMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFunctionChatMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(FunctionChatMessage)} does not support reading '{format}' format."); } - internal static FunctionChatMessage DeserializeFunctionChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionChatMessage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static FunctionChatMessage DeserializeFunctionChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ChatMessageRole role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - ChatMessageRole role = default; - IList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("role"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("role"u8)) - { - role = property.Value.GetString().ToChatMessageRole(); - continue; - } - if (property.NameEquals("content"u8)) - { - DeserializeContentValue(property, ref content); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + role = property.Value.GetString().ToChatMessageRole(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FunctionChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, name); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("content"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FunctionChatMessage)} does not support writing '{options.Format}' format."); + DeserializeContentValue(property, ref content); + continue; } - } - - FunctionChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFunctionChatMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FunctionChatMessage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, name); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new FunctionChatMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFunctionChatMessage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FunctionChatMessage)} does not support writing '{options.Format}' format."); } + } + + FunctionChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFunctionChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionChatMessage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new FunctionChatMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFunctionChatMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/FunctionChatMessage.cs b/src/Generated/Models/FunctionChatMessage.cs index 5dcbdf22..20265dd8 100644 --- a/src/Generated/Models/FunctionChatMessage.cs +++ b/src/Generated/Models/FunctionChatMessage.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class FunctionChatMessage : ChatMessage { - public partial class FunctionChatMessage : ChatMessage + internal FunctionChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string functionName) : base(role, content, serializedAdditionalRawData) { - internal FunctionChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string functionName) : base(role, content, serializedAdditionalRawData) - { - FunctionName = functionName; - } + FunctionName = functionName; + } - internal FunctionChatMessage() - { - } + internal FunctionChatMessage() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FunctionToolDefinition.Serialization.cs b/src/Generated/Models/FunctionToolDefinition.Serialization.cs index e17ea82e..dcaad246 100644 --- a/src/Generated/Models/FunctionToolDefinition.Serialization.cs +++ b/src/Generated/Models/FunctionToolDefinition.Serialization.cs @@ -8,96 +8,95 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FunctionToolDefinition : IJsonModel { - public partial class FunctionToolDefinition : IJsonModel + FunctionToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - FunctionToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFunctionToolDefinition(document.RootElement, options); + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support reading '{format}' format."); } - internal static FunctionToolDefinition DeserializeFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionToolDefinition(document.RootElement, options); + } + + internal static FunctionToolDefinition DeserializeFunctionToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalFunctionDefinition function = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) { - return null; + function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value, options); + continue; } - InternalFunctionDefinition function = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("function"u8)) - { - function = InternalFunctionDefinition.DeserializeInternalFunctionDefinition(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new FunctionToolDefinition(type, serializedAdditionalRawData, function); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionToolDefinition(type, serializedAdditionalRawData, function); + } - FunctionToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFunctionToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + FunctionToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new FunctionToolDefinition FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeFunctionToolDefinition(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFunctionToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionToolDefinition)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new FunctionToolDefinition FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFunctionToolDefinition(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/FunctionToolDefinition.cs b/src/Generated/Models/FunctionToolDefinition.cs index a1ed5ea6..258cfda1 100644 --- a/src/Generated/Models/FunctionToolDefinition.cs +++ b/src/Generated/Models/FunctionToolDefinition.cs @@ -5,9 +5,8 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class FunctionToolDefinition : ToolDefinition { - public partial class FunctionToolDefinition : ToolDefinition - { - } -} +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImage.Serialization.cs b/src/Generated/Models/GeneratedImage.Serialization.cs index cdcba781..67fda60e 100644 --- a/src/Generated/Models/GeneratedImage.Serialization.cs +++ b/src/Generated/Models/GeneratedImage.Serialization.cs @@ -8,156 +8,155 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class GeneratedImage : IJsonModel { - public partial class GeneratedImage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GeneratedImage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(GeneratedImage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("b64_json") != true && Optional.IsDefined(ImageBytes)) - { - writer.WritePropertyName("b64_json"u8); - writer.WriteBase64StringValue(ImageBytes.ToArray(), "D"); - } - if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(ImageUri)) - { - writer.WritePropertyName("url"u8); - writer.WriteStringValue(ImageUri.AbsoluteUri); - } - if (SerializedAdditionalRawData?.ContainsKey("revised_prompt") != true && Optional.IsDefined(RevisedPrompt)) - { - writer.WritePropertyName("revised_prompt"u8); - writer.WriteStringValue(RevisedPrompt); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("b64_json") != true && Optional.IsDefined(ImageBytes)) + { + writer.WritePropertyName("b64_json"u8); + writer.WriteBase64StringValue(ImageBytes.ToArray(), "D"); + } + if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(ImageUri)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(ImageUri.AbsoluteUri); + } + if (SerializedAdditionalRawData?.ContainsKey("revised_prompt") != true && Optional.IsDefined(RevisedPrompt)) + { + writer.WritePropertyName("revised_prompt"u8); + writer.WriteStringValue(RevisedPrompt); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - GeneratedImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + GeneratedImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GeneratedImage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGeneratedImage(document.RootElement, options); + throw new FormatException($"The model {nameof(GeneratedImage)} does not support reading '{format}' format."); } - internal static GeneratedImage DeserializeGeneratedImage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGeneratedImage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BinaryData b64Json = default; - Uri url = default; - string revisedPrompt = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static GeneratedImage DeserializeGeneratedImage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData b64Json = default; + Uri url = default; + string revisedPrompt = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("b64_json"u8)) { - if (property.NameEquals("b64_json"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - b64Json = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); - continue; - } - if (property.NameEquals("url"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - url = new Uri(property.Value.GetString()); continue; } - if (property.NameEquals("revised_prompt"u8)) + b64Json = BinaryData.FromBytes(property.Value.GetBytesFromBase64("D")); + continue; + } + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - revisedPrompt = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + url = new Uri(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new GeneratedImage(b64Json, url, revisedPrompt, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("revised_prompt"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(GeneratedImage)} does not support writing '{options.Format}' format."); + revisedPrompt = property.Value.GetString(); + continue; } - } - - GeneratedImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeGeneratedImage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GeneratedImage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new GeneratedImage(b64Json, url, revisedPrompt, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static GeneratedImage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeGeneratedImage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GeneratedImage)} does not support writing '{options.Format}' format."); } + } + + GeneratedImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeGeneratedImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GeneratedImage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static GeneratedImage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeGeneratedImage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImage.cs b/src/Generated/Models/GeneratedImage.cs index 9177bfc9..dd6c2807 100644 --- a/src/Generated/Models/GeneratedImage.cs +++ b/src/Generated/Models/GeneratedImage.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class GeneratedImage { - public partial class GeneratedImage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal GeneratedImage() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal GeneratedImage() - { - } + } - internal GeneratedImage(BinaryData imageBytes, Uri imageUri, string revisedPrompt, IDictionary serializedAdditionalRawData) - { - ImageBytes = imageBytes; - ImageUri = imageUri; - RevisedPrompt = revisedPrompt; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public string RevisedPrompt { get; } + internal GeneratedImage(BinaryData imageBytes, Uri imageUri, string revisedPrompt, IDictionary serializedAdditionalRawData) + { + ImageBytes = imageBytes; + ImageUri = imageUri; + RevisedPrompt = revisedPrompt; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public string RevisedPrompt { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImageCollection.Serialization.cs b/src/Generated/Models/GeneratedImageCollection.Serialization.cs index 46bcc4d4..10a9a7fc 100644 --- a/src/Generated/Models/GeneratedImageCollection.Serialization.cs +++ b/src/Generated/Models/GeneratedImageCollection.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class GeneratedImageCollection : IJsonModel { - public partial class GeneratedImageCollection : IJsonModel + GeneratedImageCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - GeneratedImageCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(GeneratedImageCollection)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeGeneratedImageCollection(document.RootElement, options); + throw new FormatException($"The model {nameof(GeneratedImageCollection)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGeneratedImageCollection(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(GeneratedImageCollection)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - GeneratedImageCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeGeneratedImageCollection(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(GeneratedImageCollection)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GeneratedImageCollection)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + GeneratedImageCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static GeneratedImageCollection FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeGeneratedImageCollection(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeGeneratedImageCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GeneratedImageCollection)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static GeneratedImageCollection FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeGeneratedImageCollection(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImageCollection.cs b/src/Generated/Models/GeneratedImageCollection.cs index 992b8ad4..2b4051a7 100644 --- a/src/Generated/Models/GeneratedImageCollection.cs +++ b/src/Generated/Models/GeneratedImageCollection.cs @@ -7,9 +7,8 @@ using System.Collections.ObjectModel; using System.Linq; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class GeneratedImageCollection : ReadOnlyCollection { - public partial class GeneratedImageCollection : ReadOnlyCollection - { - } -} +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImageFormat.Serialization.cs b/src/Generated/Models/GeneratedImageFormat.Serialization.cs index 6cbd234d..cf37829c 100644 --- a/src/Generated/Models/GeneratedImageFormat.Serialization.cs +++ b/src/Generated/Models/GeneratedImageFormat.Serialization.cs @@ -4,22 +4,21 @@ using System; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal static partial class GeneratedImageFormatExtensions { - internal static partial class GeneratedImageFormatExtensions + public static string ToSerialString(this GeneratedImageFormat value) => value switch { - public static string ToSerialString(this GeneratedImageFormat value) => value switch - { - GeneratedImageFormat.Uri => "url", - GeneratedImageFormat.Bytes => "b64_json", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageFormat value.") - }; + GeneratedImageFormat.Uri => "url", + GeneratedImageFormat.Bytes => "b64_json", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageFormat value.") + }; - public static GeneratedImageFormat ToGeneratedImageFormat(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "url")) return GeneratedImageFormat.Uri; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "b64_json")) return GeneratedImageFormat.Bytes; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageFormat value."); - } + public static GeneratedImageFormat ToGeneratedImageFormat(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "url")) return GeneratedImageFormat.Uri; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "b64_json")) return GeneratedImageFormat.Bytes; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageFormat value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImageQuality.Serialization.cs b/src/Generated/Models/GeneratedImageQuality.Serialization.cs index 96d00a50..e84321a2 100644 --- a/src/Generated/Models/GeneratedImageQuality.Serialization.cs +++ b/src/Generated/Models/GeneratedImageQuality.Serialization.cs @@ -4,22 +4,21 @@ using System; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal static partial class GeneratedImageQualityExtensions { - internal static partial class GeneratedImageQualityExtensions + public static string ToSerialString(this GeneratedImageQuality value) => value switch { - public static string ToSerialString(this GeneratedImageQuality value) => value switch - { - GeneratedImageQuality.Standard => "standard", - GeneratedImageQuality.High => "hd", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageQuality value.") - }; + GeneratedImageQuality.Standard => "standard", + GeneratedImageQuality.High => "hd", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageQuality value.") + }; - public static GeneratedImageQuality ToGeneratedImageQuality(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "standard")) return GeneratedImageQuality.Standard; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "hd")) return GeneratedImageQuality.High; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageQuality value."); - } + public static GeneratedImageQuality ToGeneratedImageQuality(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "standard")) return GeneratedImageQuality.Standard; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "hd")) return GeneratedImageQuality.High; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageQuality value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImageSize.cs b/src/Generated/Models/GeneratedImageSize.cs index 8a16802a..8af6e2e0 100644 --- a/src/Generated/Models/GeneratedImageSize.cs +++ b/src/Generated/Models/GeneratedImageSize.cs @@ -5,24 +5,23 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +public readonly partial struct GeneratedImageSize : IEquatable { - public readonly partial struct GeneratedImageSize : IEquatable - { - private const string W256xH256Value = "256x256"; - private const string W512xH512Value = "512x512"; - private const string W1024xH1024Value = "1024x1024"; - private const string W1024xH1792Value = "1792x1024"; - private const string W1792xH1024Value = "1024x1792"; - public static bool operator ==(GeneratedImageSize left, GeneratedImageSize right) => left.Equals(right); - public static bool operator !=(GeneratedImageSize left, GeneratedImageSize right) => !left.Equals(right); + private const string W256xH256Value = "256x256"; + private const string W512xH512Value = "512x512"; + private const string W1024xH1024Value = "1024x1024"; + private const string W1024xH1792Value = "1792x1024"; + private const string W1792xH1024Value = "1024x1792"; + public static bool operator ==(GeneratedImageSize left, GeneratedImageSize right) => left.Equals(right); + public static bool operator !=(GeneratedImageSize left, GeneratedImageSize right) => !left.Equals(right); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is GeneratedImageSize other && Equals(other); - public bool Equals(GeneratedImageSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GeneratedImageSize other && Equals(other); + public bool Equals(GeneratedImageSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedImageStyle.Serialization.cs b/src/Generated/Models/GeneratedImageStyle.Serialization.cs index ebb7cbd7..80ad1d5d 100644 --- a/src/Generated/Models/GeneratedImageStyle.Serialization.cs +++ b/src/Generated/Models/GeneratedImageStyle.Serialization.cs @@ -4,22 +4,21 @@ using System; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal static partial class GeneratedImageStyleExtensions { - internal static partial class GeneratedImageStyleExtensions + public static string ToSerialString(this GeneratedImageStyle value) => value switch { - public static string ToSerialString(this GeneratedImageStyle value) => value switch - { - GeneratedImageStyle.Vivid => "vivid", - GeneratedImageStyle.Natural => "natural", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageStyle value.") - }; + GeneratedImageStyle.Vivid => "vivid", + GeneratedImageStyle.Natural => "natural", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageStyle value.") + }; - public static GeneratedImageStyle ToGeneratedImageStyle(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "vivid")) return GeneratedImageStyle.Vivid; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "natural")) return GeneratedImageStyle.Natural; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageStyle value."); - } + public static GeneratedImageStyle ToGeneratedImageStyle(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "vivid")) return GeneratedImageStyle.Vivid; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "natural")) return GeneratedImageStyle.Natural; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown GeneratedImageStyle value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedSpeechFormat.cs b/src/Generated/Models/GeneratedSpeechFormat.cs index e8c256e3..41555207 100644 --- a/src/Generated/Models/GeneratedSpeechFormat.cs +++ b/src/Generated/Models/GeneratedSpeechFormat.cs @@ -5,40 +5,39 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public readonly partial struct GeneratedSpeechFormat : IEquatable { - public readonly partial struct GeneratedSpeechFormat : IEquatable + private readonly string _value; + + public GeneratedSpeechFormat(string value) { - private readonly string _value; - - public GeneratedSpeechFormat(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string Mp3Value = "mp3"; - private const string OpusValue = "opus"; - private const string AacValue = "aac"; - private const string FlacValue = "flac"; - private const string WavValue = "wav"; - private const string PcmValue = "pcm"; - - public static GeneratedSpeechFormat Mp3 { get; } = new GeneratedSpeechFormat(Mp3Value); - public static GeneratedSpeechFormat Opus { get; } = new GeneratedSpeechFormat(OpusValue); - public static GeneratedSpeechFormat Aac { get; } = new GeneratedSpeechFormat(AacValue); - public static GeneratedSpeechFormat Flac { get; } = new GeneratedSpeechFormat(FlacValue); - public static GeneratedSpeechFormat Wav { get; } = new GeneratedSpeechFormat(WavValue); - public static GeneratedSpeechFormat Pcm { get; } = new GeneratedSpeechFormat(PcmValue); - public static bool operator ==(GeneratedSpeechFormat left, GeneratedSpeechFormat right) => left.Equals(right); - public static bool operator !=(GeneratedSpeechFormat left, GeneratedSpeechFormat right) => !left.Equals(right); - public static implicit operator GeneratedSpeechFormat(string value) => new GeneratedSpeechFormat(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is GeneratedSpeechFormat other && Equals(other); - public bool Equals(GeneratedSpeechFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string Mp3Value = "mp3"; + private const string OpusValue = "opus"; + private const string AacValue = "aac"; + private const string FlacValue = "flac"; + private const string WavValue = "wav"; + private const string PcmValue = "pcm"; + + public static GeneratedSpeechFormat Mp3 { get; } = new GeneratedSpeechFormat(Mp3Value); + public static GeneratedSpeechFormat Opus { get; } = new GeneratedSpeechFormat(OpusValue); + public static GeneratedSpeechFormat Aac { get; } = new GeneratedSpeechFormat(AacValue); + public static GeneratedSpeechFormat Flac { get; } = new GeneratedSpeechFormat(FlacValue); + public static GeneratedSpeechFormat Wav { get; } = new GeneratedSpeechFormat(WavValue); + public static GeneratedSpeechFormat Pcm { get; } = new GeneratedSpeechFormat(PcmValue); + public static bool operator ==(GeneratedSpeechFormat left, GeneratedSpeechFormat right) => left.Equals(right); + public static bool operator !=(GeneratedSpeechFormat left, GeneratedSpeechFormat right) => !left.Equals(right); + public static implicit operator GeneratedSpeechFormat(string value) => new GeneratedSpeechFormat(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GeneratedSpeechFormat other && Equals(other); + public bool Equals(GeneratedSpeechFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/GeneratedSpeechVoice.cs b/src/Generated/Models/GeneratedSpeechVoice.cs index 14fad742..4539c780 100644 --- a/src/Generated/Models/GeneratedSpeechVoice.cs +++ b/src/Generated/Models/GeneratedSpeechVoice.cs @@ -5,40 +5,39 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public readonly partial struct GeneratedSpeechVoice : IEquatable { - public readonly partial struct GeneratedSpeechVoice : IEquatable + private readonly string _value; + + public GeneratedSpeechVoice(string value) { - private readonly string _value; - - public GeneratedSpeechVoice(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AlloyValue = "alloy"; - private const string EchoValue = "echo"; - private const string FableValue = "fable"; - private const string OnyxValue = "onyx"; - private const string NovaValue = "nova"; - private const string ShimmerValue = "shimmer"; - - public static GeneratedSpeechVoice Alloy { get; } = new GeneratedSpeechVoice(AlloyValue); - public static GeneratedSpeechVoice Echo { get; } = new GeneratedSpeechVoice(EchoValue); - public static GeneratedSpeechVoice Fable { get; } = new GeneratedSpeechVoice(FableValue); - public static GeneratedSpeechVoice Onyx { get; } = new GeneratedSpeechVoice(OnyxValue); - public static GeneratedSpeechVoice Nova { get; } = new GeneratedSpeechVoice(NovaValue); - public static GeneratedSpeechVoice Shimmer { get; } = new GeneratedSpeechVoice(ShimmerValue); - public static bool operator ==(GeneratedSpeechVoice left, GeneratedSpeechVoice right) => left.Equals(right); - public static bool operator !=(GeneratedSpeechVoice left, GeneratedSpeechVoice right) => !left.Equals(right); - public static implicit operator GeneratedSpeechVoice(string value) => new GeneratedSpeechVoice(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is GeneratedSpeechVoice other && Equals(other); - public bool Equals(GeneratedSpeechVoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AlloyValue = "alloy"; + private const string EchoValue = "echo"; + private const string FableValue = "fable"; + private const string OnyxValue = "onyx"; + private const string NovaValue = "nova"; + private const string ShimmerValue = "shimmer"; + + public static GeneratedSpeechVoice Alloy { get; } = new GeneratedSpeechVoice(AlloyValue); + public static GeneratedSpeechVoice Echo { get; } = new GeneratedSpeechVoice(EchoValue); + public static GeneratedSpeechVoice Fable { get; } = new GeneratedSpeechVoice(FableValue); + public static GeneratedSpeechVoice Onyx { get; } = new GeneratedSpeechVoice(OnyxValue); + public static GeneratedSpeechVoice Nova { get; } = new GeneratedSpeechVoice(NovaValue); + public static GeneratedSpeechVoice Shimmer { get; } = new GeneratedSpeechVoice(ShimmerValue); + public static bool operator ==(GeneratedSpeechVoice left, GeneratedSpeechVoice right) => left.Equals(right); + public static bool operator !=(GeneratedSpeechVoice left, GeneratedSpeechVoice right) => !left.Equals(right); + public static implicit operator GeneratedSpeechVoice(string value) => new GeneratedSpeechVoice(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GeneratedSpeechVoice other && Equals(other); + public bool Equals(GeneratedSpeechVoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/HyperparameterBatchSize.cs b/src/Generated/Models/HyperparameterBatchSize.cs index c0fc1a7e..2571d017 100644 --- a/src/Generated/Models/HyperparameterBatchSize.cs +++ b/src/Generated/Models/HyperparameterBatchSize.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct HyperparameterBatchSize : IEquatable { - internal readonly partial struct HyperparameterBatchSize : IEquatable - { - private readonly string _value; + private readonly string _value; - public HyperparameterBatchSize(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public HyperparameterBatchSize(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; + private const string AutoValue = "auto"; - public static HyperparameterBatchSize Auto { get; } = new HyperparameterBatchSize(AutoValue); - public static bool operator ==(HyperparameterBatchSize left, HyperparameterBatchSize right) => left.Equals(right); - public static bool operator !=(HyperparameterBatchSize left, HyperparameterBatchSize right) => !left.Equals(right); - public static implicit operator HyperparameterBatchSize(string value) => new HyperparameterBatchSize(value); + public static HyperparameterBatchSize Auto { get; } = new HyperparameterBatchSize(AutoValue); + public static bool operator ==(HyperparameterBatchSize left, HyperparameterBatchSize right) => left.Equals(right); + public static bool operator !=(HyperparameterBatchSize left, HyperparameterBatchSize right) => !left.Equals(right); + public static implicit operator HyperparameterBatchSize(string value) => new HyperparameterBatchSize(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is HyperparameterBatchSize other && Equals(other); - public bool Equals(HyperparameterBatchSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is HyperparameterBatchSize other && Equals(other); + public bool Equals(HyperparameterBatchSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/HyperparameterCycleCount.cs b/src/Generated/Models/HyperparameterCycleCount.cs index 3f55bc83..cda4bcfb 100644 --- a/src/Generated/Models/HyperparameterCycleCount.cs +++ b/src/Generated/Models/HyperparameterCycleCount.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct HyperparameterCycleCount : IEquatable { - internal readonly partial struct HyperparameterCycleCount : IEquatable - { - private readonly string _value; + private readonly string _value; - public HyperparameterCycleCount(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public HyperparameterCycleCount(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; + private const string AutoValue = "auto"; - public static HyperparameterCycleCount Auto { get; } = new HyperparameterCycleCount(AutoValue); - public static bool operator ==(HyperparameterCycleCount left, HyperparameterCycleCount right) => left.Equals(right); - public static bool operator !=(HyperparameterCycleCount left, HyperparameterCycleCount right) => !left.Equals(right); - public static implicit operator HyperparameterCycleCount(string value) => new HyperparameterCycleCount(value); + public static HyperparameterCycleCount Auto { get; } = new HyperparameterCycleCount(AutoValue); + public static bool operator ==(HyperparameterCycleCount left, HyperparameterCycleCount right) => left.Equals(right); + public static bool operator !=(HyperparameterCycleCount left, HyperparameterCycleCount right) => !left.Equals(right); + public static implicit operator HyperparameterCycleCount(string value) => new HyperparameterCycleCount(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is HyperparameterCycleCount other && Equals(other); - public bool Equals(HyperparameterCycleCount other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is HyperparameterCycleCount other && Equals(other); + public bool Equals(HyperparameterCycleCount other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/HyperparameterLearningRate.cs b/src/Generated/Models/HyperparameterLearningRate.cs index a40fbb8d..c116f7d8 100644 --- a/src/Generated/Models/HyperparameterLearningRate.cs +++ b/src/Generated/Models/HyperparameterLearningRate.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct HyperparameterLearningRate : IEquatable { - internal readonly partial struct HyperparameterLearningRate : IEquatable - { - private readonly string _value; + private readonly string _value; - public HyperparameterLearningRate(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public HyperparameterLearningRate(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; + private const string AutoValue = "auto"; - public static HyperparameterLearningRate Auto { get; } = new HyperparameterLearningRate(AutoValue); - public static bool operator ==(HyperparameterLearningRate left, HyperparameterLearningRate right) => left.Equals(right); - public static bool operator !=(HyperparameterLearningRate left, HyperparameterLearningRate right) => !left.Equals(right); - public static implicit operator HyperparameterLearningRate(string value) => new HyperparameterLearningRate(value); + public static HyperparameterLearningRate Auto { get; } = new HyperparameterLearningRate(AutoValue); + public static bool operator ==(HyperparameterLearningRate left, HyperparameterLearningRate right) => left.Equals(right); + public static bool operator !=(HyperparameterLearningRate left, HyperparameterLearningRate right) => !left.Equals(right); + public static implicit operator HyperparameterLearningRate(string value) => new HyperparameterLearningRate(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is HyperparameterLearningRate other && Equals(other); - public bool Equals(HyperparameterLearningRate other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is HyperparameterLearningRate other && Equals(other); + public bool Equals(HyperparameterLearningRate other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/HyperparameterOptions.Serialization.cs b/src/Generated/Models/HyperparameterOptions.Serialization.cs index 6ccb4492..b33ae4ac 100644 --- a/src/Generated/Models/HyperparameterOptions.Serialization.cs +++ b/src/Generated/Models/HyperparameterOptions.Serialization.cs @@ -8,181 +8,180 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class HyperparameterOptions : IJsonModel { - internal partial class HyperparameterOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("n_epochs") != true && Optional.IsDefined(NEpochs)) - { - writer.WritePropertyName("n_epochs"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("n_epochs") != true && Optional.IsDefined(NEpochs)) + { + writer.WritePropertyName("n_epochs"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(NEpochs); #else - using (JsonDocument document = JsonDocument.Parse(NEpochs)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("batch_size") != true && Optional.IsDefined(BatchSize)) + using (JsonDocument document = JsonDocument.Parse(NEpochs)) { - writer.WritePropertyName("batch_size"u8); + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("batch_size") != true && Optional.IsDefined(BatchSize)) + { + writer.WritePropertyName("batch_size"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(BatchSize); #else - using (JsonDocument document = JsonDocument.Parse(BatchSize)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("learning_rate_multiplier") != true && Optional.IsDefined(LearningRateMultiplier)) + using (JsonDocument document = JsonDocument.Parse(BatchSize)) { - writer.WritePropertyName("learning_rate_multiplier"u8); + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("learning_rate_multiplier") != true && Optional.IsDefined(LearningRateMultiplier)) + { + writer.WritePropertyName("learning_rate_multiplier"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(LearningRateMultiplier); #else - using (JsonDocument document = JsonDocument.Parse(LearningRateMultiplier)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(LearningRateMultiplier)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - HyperparameterOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + HyperparameterOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeHyperparameterOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support reading '{format}' format."); } - internal static HyperparameterOptions DeserializeHyperparameterOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHyperparameterOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - BinaryData nEpochs = default; - BinaryData batchSize = default; - BinaryData learningRateMultiplier = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static HyperparameterOptions DeserializeHyperparameterOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData nEpochs = default; + BinaryData batchSize = default; + BinaryData learningRateMultiplier = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("n_epochs"u8)) { - if (property.NameEquals("n_epochs"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - nEpochs = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (property.NameEquals("batch_size"u8)) + nEpochs = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("batch_size"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - batchSize = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (property.NameEquals("learning_rate_multiplier"u8)) + batchSize = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("learning_rate_multiplier"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - learningRateMultiplier = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + learningRateMultiplier = BinaryData.FromString(property.Value.GetRawText()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new HyperparameterOptions(nEpochs, batchSize, learningRateMultiplier, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new HyperparameterOptions(nEpochs, batchSize, learningRateMultiplier, serializedAdditionalRawData); + } - HyperparameterOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeHyperparameterOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + HyperparameterOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static HyperparameterOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeHyperparameterOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeHyperparameterOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HyperparameterOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static HyperparameterOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeHyperparameterOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/HyperparameterOptions.cs b/src/Generated/Models/HyperparameterOptions.cs index 06e35aa0..a2e1f09c 100644 --- a/src/Generated/Models/HyperparameterOptions.cs +++ b/src/Generated/Models/HyperparameterOptions.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class HyperparameterOptions { - internal partial class HyperparameterOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public HyperparameterOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public HyperparameterOptions() - { - } - - internal HyperparameterOptions(BinaryData nEpochs, BinaryData batchSize, BinaryData learningRateMultiplier, IDictionary serializedAdditionalRawData) - { - NEpochs = nEpochs; - BatchSize = batchSize; - LearningRateMultiplier = learningRateMultiplier; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public BinaryData NEpochs { get; set; } - public BinaryData BatchSize { get; set; } - public BinaryData LearningRateMultiplier { get; set; } + internal HyperparameterOptions(BinaryData nEpochs, BinaryData batchSize, BinaryData learningRateMultiplier, IDictionary serializedAdditionalRawData) + { + NEpochs = nEpochs; + BatchSize = batchSize; + LearningRateMultiplier = learningRateMultiplier; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public BinaryData NEpochs { get; set; } + public BinaryData BatchSize { get; set; } + public BinaryData LearningRateMultiplier { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ImageEditOptions.Serialization.cs b/src/Generated/Models/ImageEditOptions.Serialization.cs index 45e61401..258d6174 100644 --- a/src/Generated/Models/ImageEditOptions.Serialization.cs +++ b/src/Generated/Models/ImageEditOptions.Serialization.cs @@ -9,339 +9,338 @@ using System.IO; using System.Text.Json; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class ImageEditOptions : IJsonModel { - public partial class ImageEditOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ImageEditOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ImageEditOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("image") != true) - { - writer.WritePropertyName("image"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("image") != true) + { + writer.WritePropertyName("image"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Image); #else - using (JsonDocument document = JsonDocument.Parse(Image)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("prompt") != true) + using (JsonDocument document = JsonDocument.Parse(Image)) { - writer.WritePropertyName("prompt"u8); - writer.WriteStringValue(Prompt); + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData?.ContainsKey("mask") != true && Optional.IsDefined(Mask)) - { - writer.WritePropertyName("mask"u8); +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("prompt") != true) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (SerializedAdditionalRawData?.ContainsKey("mask") != true && Optional.IsDefined(Mask)) + { + writer.WritePropertyName("mask"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Mask); #else - using (JsonDocument document = JsonDocument.Parse(Mask)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(Mask)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + { + if (Model != null) { - if (Model != null) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.Value.ToString()); - } - else - { - writer.WriteNull("model"); - } + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + else { - if (N != null) - { - writer.WritePropertyName("n"u8); - writer.WriteNumberValue(N.Value); - } - else - { - writer.WriteNull("n"); - } + writer.WriteNull("model"); } - if (SerializedAdditionalRawData?.ContainsKey("size") != true && Optional.IsDefined(Size)) + } + if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + { + if (N != null) { - if (Size != null) - { - writer.WritePropertyName("size"u8); - writer.WriteStringValue(Size.Value.ToString()); - } - else - { - writer.WriteNull("size"); - } + writer.WritePropertyName("n"u8); + writer.WriteNumberValue(N.Value); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + else { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); - } - else - { - writer.WriteNull("response_format"); - } + writer.WriteNull("n"); } - if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + } + if (SerializedAdditionalRawData?.ContainsKey("size") != true && Optional.IsDefined(Size)) + { + if (Size != null) { - writer.WritePropertyName("user"u8); - writer.WriteStringValue(EndUserId); + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size.Value.ToString()); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + writer.WriteNull("size"); } - writer.WriteEndObject(); } - - ImageEditOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (ResponseFormat != null) { - throw new FormatException($"The model {nameof(ImageEditOptions)} does not support reading '{format}' format."); + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeImageEditOptions(document.RootElement, options); - } - - internal static ImageEditOptions DeserializeImageEditOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) + else { - return null; + writer.WriteNull("response_format"); } - BinaryData image = default; - string prompt = default; - BinaryData mask = default; - InternalCreateImageEditRequestModel? model = default; - long? n = default; - GeneratedImageSize? size = default; - GeneratedImageFormat? responseFormat = default; - string user = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + } + if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(EndUserId); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("image"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - image = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (property.NameEquals("prompt"u8)) - { - prompt = property.Value.GetString(); - continue; - } - if (property.NameEquals("mask"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - mask = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("model"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - model = null; - continue; - } - model = new InternalCreateImageEditRequestModel(property.Value.GetString()); - continue; - } - if (property.NameEquals("n"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - n = null; - continue; - } - n = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("size"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - size = null; - continue; - } - size = new GeneratedImageSize(property.Value.GetString()); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = property.Value.GetString().ToGeneratedImageFormat(); - continue; - } - if (property.NameEquals("user"u8)) - { - user = property.Value.GetString(); - continue; - } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new ImageEditOptions( - image, - prompt, - mask, - model, - n, - size, - responseFormat, - user, - serializedAdditionalRawData); } + writer.WriteEndObject(); + } + + ImageEditOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageEditOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageEditOptions(document.RootElement, options); + } + + internal static ImageEditOptions DeserializeImageEditOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); - using MemoryStream stream = new MemoryStream(); - content.WriteTo(stream); - if (stream.Position > int.MaxValue) + return null; + } + BinaryData image = default; + string prompt = default; + BinaryData mask = default; + InternalCreateImageEditRequestModel? model = default; + long? n = default; + GeneratedImageSize? size = default; + GeneratedImageFormat? responseFormat = default; + string user = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) { - return BinaryData.FromStream(stream); + image = BinaryData.FromString(property.Value.GetRawText()); + continue; } - else + if (property.NameEquals("prompt"u8)) { - return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + prompt = property.Value.GetString(); + continue; } - } - - internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() - { - MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); - content.Add(Image, "image", "image"); - content.Add(Prompt, "prompt"); - if (Optional.IsDefined(Mask)) + if (property.NameEquals("mask"u8)) { - content.Add(Mask, "mask", "mask"); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mask = BinaryData.FromString(property.Value.GetRawText()); + continue; } - if (Optional.IsDefined(Model)) + if (property.NameEquals("model"u8)) { - if (Model != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(Model.Value.ToString(), "model"); + model = null; + continue; } + model = new InternalCreateImageEditRequestModel(property.Value.GetString()); + continue; } - if (Optional.IsDefined(N)) + if (property.NameEquals("n"u8)) { - if (N != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(N.Value, "n"); + n = null; + continue; } + n = property.Value.GetInt64(); + continue; } - if (Optional.IsDefined(Size)) + if (property.NameEquals("size"u8)) { - if (Size != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(Size.Value.ToString(), "size"); + size = null; + continue; } + size = new GeneratedImageSize(property.Value.GetString()); + continue; } - if (Optional.IsDefined(ResponseFormat)) + if (property.NameEquals("response_format"u8)) { - if (ResponseFormat != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); + responseFormat = null; + continue; } + responseFormat = property.Value.GetString().ToGeneratedImageFormat(); + continue; } - if (Optional.IsDefined(EndUserId)) + if (property.NameEquals("user"u8)) { - content.Add(EndUserId, "user"); + user = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - return content; } + serializedAdditionalRawData = rawDataDictionary; + return new ImageEditOptions( + image, + prompt, + mask, + model, + n, + size, + responseFormat, + user, + serializedAdditionalRawData); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) + { + return BinaryData.FromStream(stream); + } + else { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + } + } - switch (format) + internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + { + MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); + content.Add(Image, "image", "image"); + content.Add(Prompt, "prompt"); + if (Optional.IsDefined(Mask)) + { + content.Add(Mask, "mask", "mask"); + } + if (Optional.IsDefined(Model)) + { + if (Model != null) { - case "J": - return ModelReaderWriter.Write(this, options); - case "MFD": - return SerializeMultipart(options); - default: - throw new FormatException($"The model {nameof(ImageEditOptions)} does not support writing '{options.Format}' format."); + content.Add(Model.Value.ToString(), "model"); } } - - ImageEditOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (Optional.IsDefined(N)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (N != null) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeImageEditOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ImageEditOptions)} does not support reading '{options.Format}' format."); + content.Add(N.Value, "n"); } } + if (Optional.IsDefined(Size)) + { + if (Size != null) + { + content.Add(Size.Value.ToString(), "size"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); + } + } + if (Optional.IsDefined(EndUserId)) + { + content.Add(EndUserId, "user"); + } + return content; + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ImageEditOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeImageEditOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(ImageEditOptions)} does not support writing '{options.Format}' format."); } + } + + ImageEditOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeImageEditOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageEditOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + internal static ImageEditOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeImageEditOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ImageEditOptions.cs b/src/Generated/Models/ImageEditOptions.cs index c46d7879..c2581ebb 100644 --- a/src/Generated/Models/ImageEditOptions.cs +++ b/src/Generated/Models/ImageEditOptions.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class ImageEditOptions { - public partial class ImageEditOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ImageEditOptions(BinaryData image, string prompt, BinaryData mask, InternalCreateImageEditRequestModel? model, long? n, GeneratedImageSize? size, GeneratedImageFormat? responseFormat, string endUserId, IDictionary serializedAdditionalRawData) - { - Image = image; - Prompt = prompt; - Mask = mask; - Model = model; - N = n; - Size = size; - ResponseFormat = responseFormat; - EndUserId = endUserId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ImageEditOptions(BinaryData image, string prompt, BinaryData mask, InternalCreateImageEditRequestModel? model, long? n, GeneratedImageSize? size, GeneratedImageFormat? responseFormat, string endUserId, IDictionary serializedAdditionalRawData) + { + Image = image; + Prompt = prompt; + Mask = mask; + Model = model; + N = n; + Size = size; + ResponseFormat = responseFormat; + EndUserId = endUserId; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ImageGenerationOptions.Serialization.cs b/src/Generated/Models/ImageGenerationOptions.Serialization.cs index a007fd04..40b6a69d 100644 --- a/src/Generated/Models/ImageGenerationOptions.Serialization.cs +++ b/src/Generated/Models/ImageGenerationOptions.Serialization.cs @@ -8,276 +8,275 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class ImageGenerationOptions : IJsonModel { - public partial class ImageGenerationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("prompt") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + { + if (Model != null) { - throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.Value.ToString()); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("prompt") != true) + else { - writer.WritePropertyName("prompt"u8); - writer.WriteStringValue(Prompt); + writer.WriteNull("model"); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + } + if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + { + if (N != null) { - if (Model != null) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.Value.ToString()); - } - else - { - writer.WriteNull("model"); - } + writer.WritePropertyName("n"u8); + writer.WriteNumberValue(N.Value); } - if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + else { - if (N != null) - { - writer.WritePropertyName("n"u8); - writer.WriteNumberValue(N.Value); - } - else - { - writer.WriteNull("n"); - } + writer.WriteNull("n"); } - if (SerializedAdditionalRawData?.ContainsKey("quality") != true && Optional.IsDefined(Quality)) + } + if (SerializedAdditionalRawData?.ContainsKey("quality") != true && Optional.IsDefined(Quality)) + { + writer.WritePropertyName("quality"u8); + writer.WriteStringValue(Quality.Value.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) { - writer.WritePropertyName("quality"u8); - writer.WriteStringValue(Quality.Value.ToSerialString()); + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + else { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); - } - else - { - writer.WriteNull("response_format"); - } + writer.WriteNull("response_format"); } - if (SerializedAdditionalRawData?.ContainsKey("size") != true && Optional.IsDefined(Size)) + } + if (SerializedAdditionalRawData?.ContainsKey("size") != true && Optional.IsDefined(Size)) + { + if (Size != null) { - if (Size != null) - { - writer.WritePropertyName("size"u8); - writer.WriteStringValue(Size.Value.ToString()); - } - else - { - writer.WriteNull("size"); - } + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("style") != true && Optional.IsDefined(Style)) + else { - if (Style != null) - { - writer.WritePropertyName("style"u8); - writer.WriteStringValue(Style.Value.ToSerialString()); - } - else - { - writer.WriteNull("style"); - } + writer.WriteNull("size"); } - if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + } + if (SerializedAdditionalRawData?.ContainsKey("style") != true && Optional.IsDefined(Style)) + { + if (Style != null) { - writer.WritePropertyName("user"u8); - writer.WriteStringValue(EndUserId); + writer.WritePropertyName("style"u8); + writer.WriteStringValue(Style.Value.ToSerialString()); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("style"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(EndUserId); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ImageGenerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ImageGenerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeImageGenerationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support reading '{format}' format."); } - internal static ImageGenerationOptions DeserializeImageGenerationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageGenerationOptions(document.RootElement, options); + } + + internal static ImageGenerationOptions DeserializeImageGenerationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string prompt = default; + InternalCreateImageRequestModel? model = default; + long? n = default; + GeneratedImageQuality? quality = default; + GeneratedImageFormat? responseFormat = default; + GeneratedImageSize? size = default; + GeneratedImageStyle? style = default; + string user = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("prompt"u8)) { - return null; + prompt = property.Value.GetString(); + continue; } - string prompt = default; - InternalCreateImageRequestModel? model = default; - long? n = default; - GeneratedImageQuality? quality = default; - GeneratedImageFormat? responseFormat = default; - GeneratedImageSize? size = default; - GeneratedImageStyle? style = default; - string user = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("model"u8)) { - if (property.NameEquals("prompt"u8)) - { - prompt = property.Value.GetString(); - continue; - } - if (property.NameEquals("model"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - model = null; - continue; - } - model = new InternalCreateImageRequestModel(property.Value.GetString()); + model = null; continue; } - if (property.NameEquals("n"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - n = null; - continue; - } - n = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("quality"u8)) + model = new InternalCreateImageRequestModel(property.Value.GetString()); + continue; + } + if (property.NameEquals("n"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - quality = property.Value.GetString().ToGeneratedImageQuality(); + n = null; continue; } - if (property.NameEquals("response_format"u8)) + n = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("quality"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = property.Value.GetString().ToGeneratedImageFormat(); continue; } - if (property.NameEquals("size"u8)) + quality = property.Value.GetString().ToGeneratedImageQuality(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - size = null; - continue; - } - size = new GeneratedImageSize(property.Value.GetString()); + responseFormat = null; continue; } - if (property.NameEquals("style"u8)) + responseFormat = property.Value.GetString().ToGeneratedImageFormat(); + continue; + } + if (property.NameEquals("size"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - style = null; - continue; - } - style = property.Value.GetString().ToGeneratedImageStyle(); + size = null; continue; } - if (property.NameEquals("user"u8)) + size = new GeneratedImageSize(property.Value.GetString()); + continue; + } + if (property.NameEquals("style"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - user = property.Value.GetString(); + style = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + style = property.Value.GetString().ToGeneratedImageStyle(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ImageGenerationOptions( - prompt, - model, - n, - quality, - responseFormat, - size, - style, - user, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("user"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support writing '{options.Format}' format."); + user = property.Value.GetString(); + continue; } - } - - ImageGenerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeImageGenerationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ImageGenerationOptions( + prompt, + model, + n, + quality, + responseFormat, + size, + style, + user, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ImageGenerationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeImageGenerationOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support writing '{options.Format}' format."); } + } + + ImageGenerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeImageGenerationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageGenerationOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ImageGenerationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeImageGenerationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ImageGenerationOptions.cs b/src/Generated/Models/ImageGenerationOptions.cs index e7d9311d..98f38289 100644 --- a/src/Generated/Models/ImageGenerationOptions.cs +++ b/src/Generated/Models/ImageGenerationOptions.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class ImageGenerationOptions { - public partial class ImageGenerationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ImageGenerationOptions(string prompt, InternalCreateImageRequestModel? model, long? n, GeneratedImageQuality? quality, GeneratedImageFormat? responseFormat, GeneratedImageSize? size, GeneratedImageStyle? style, string endUserId, IDictionary serializedAdditionalRawData) - { - Prompt = prompt; - Model = model; - N = n; - Quality = quality; - ResponseFormat = responseFormat; - Size = size; - Style = style; - EndUserId = endUserId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public GeneratedImageQuality? Quality { get; set; } - public GeneratedImageFormat? ResponseFormat { get; set; } - public GeneratedImageSize? Size { get; set; } - public GeneratedImageStyle? Style { get; set; } + internal ImageGenerationOptions(string prompt, InternalCreateImageRequestModel? model, long? n, GeneratedImageQuality? quality, GeneratedImageFormat? responseFormat, GeneratedImageSize? size, GeneratedImageStyle? style, string endUserId, IDictionary serializedAdditionalRawData) + { + Prompt = prompt; + Model = model; + N = n; + Quality = quality; + ResponseFormat = responseFormat; + Size = size; + Style = style; + EndUserId = endUserId; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public GeneratedImageQuality? Quality { get; set; } + public GeneratedImageFormat? ResponseFormat { get; set; } + public GeneratedImageSize? Size { get; set; } + public GeneratedImageStyle? Style { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ImageVariationOptions.Serialization.cs b/src/Generated/Models/ImageVariationOptions.Serialization.cs index aea32c3d..1e508bd4 100644 --- a/src/Generated/Models/ImageVariationOptions.Serialization.cs +++ b/src/Generated/Models/ImageVariationOptions.Serialization.cs @@ -9,299 +9,298 @@ using System.IO; using System.Text.Json; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class ImageVariationOptions : IJsonModel { - public partial class ImageVariationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("image") != true) - { - writer.WritePropertyName("image"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("image") != true) + { + writer.WritePropertyName("image"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Image); #else - using (JsonDocument document = JsonDocument.Parse(Image)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(Image)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + { + if (Model != null) { - if (Model != null) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.Value.ToString()); - } - else - { - writer.WriteNull("model"); - } + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + else { - if (N != null) - { - writer.WritePropertyName("n"u8); - writer.WriteNumberValue(N.Value); - } - else - { - writer.WriteNull("n"); - } + writer.WriteNull("model"); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + } + if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + { + if (N != null) { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); - } - else - { - writer.WriteNull("response_format"); - } + writer.WritePropertyName("n"u8); + writer.WriteNumberValue(N.Value); } - if (SerializedAdditionalRawData?.ContainsKey("size") != true && Optional.IsDefined(Size)) + else { - if (Size != null) - { - writer.WritePropertyName("size"u8); - writer.WriteStringValue(Size.Value.ToString()); - } - else - { - writer.WriteNull("size"); - } + writer.WriteNull("n"); } - if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) { - writer.WritePropertyName("user"u8); - writer.WriteStringValue(EndUserId); + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToSerialString()); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + writer.WriteNull("response_format"); } - writer.WriteEndObject(); } - - ImageVariationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + if (SerializedAdditionalRawData?.ContainsKey("size") != true && Optional.IsDefined(Size)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (Size != null) { - throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support reading '{format}' format."); + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size.Value.ToString()); } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeImageVariationOptions(document.RootElement, options); - } - - internal static ImageVariationOptions DeserializeImageVariationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) + else { - return null; + writer.WriteNull("size"); } - BinaryData image = default; - InternalCreateImageVariationRequestModel? model = default; - long? n = default; - GeneratedImageFormat? responseFormat = default; - GeneratedImageSize? size = default; - string user = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + } + if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(EndUserId)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(EndUserId); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("image"u8)) - { - image = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("model"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - model = null; - continue; - } - model = new InternalCreateImageVariationRequestModel(property.Value.GetString()); continue; } - if (property.NameEquals("n"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - n = null; - continue; - } - n = property.Value.GetInt64(); - continue; - } - if (property.NameEquals("response_format"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = property.Value.GetString().ToGeneratedImageFormat(); - continue; - } - if (property.NameEquals("size"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - size = null; - continue; - } - size = new GeneratedImageSize(property.Value.GetString()); - continue; - } - if (property.NameEquals("user"u8)) - { - user = property.Value.GetString(); - continue; - } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new ImageVariationOptions( - image, - model, - n, - responseFormat, - size, - user, - serializedAdditionalRawData); } + writer.WriteEndObject(); + } - private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + ImageVariationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); - using MemoryStream stream = new MemoryStream(); - content.WriteTo(stream); - if (stream.Position > int.MaxValue) - { - return BinaryData.FromStream(stream); - } - else - { - return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); - } + throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support reading '{format}' format."); } - internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageVariationOptions(document.RootElement, options); + } + + internal static ImageVariationOptions DeserializeImageVariationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) { - MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); - content.Add(Image, "image", "image"); - if (Optional.IsDefined(Model)) + return null; + } + BinaryData image = default; + InternalCreateImageVariationRequestModel? model = default; + long? n = default; + GeneratedImageFormat? responseFormat = default; + GeneratedImageSize? size = default; + string user = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) + { + image = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("model"u8)) { - if (Model != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(Model.Value.ToString(), "model"); + model = null; + continue; } + model = new InternalCreateImageVariationRequestModel(property.Value.GetString()); + continue; } - if (Optional.IsDefined(N)) + if (property.NameEquals("n"u8)) { - if (N != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(N.Value, "n"); + n = null; + continue; } + n = property.Value.GetInt64(); + continue; } - if (Optional.IsDefined(ResponseFormat)) + if (property.NameEquals("response_format"u8)) { - if (ResponseFormat != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); + responseFormat = null; + continue; } + responseFormat = property.Value.GetString().ToGeneratedImageFormat(); + continue; } - if (Optional.IsDefined(Size)) + if (property.NameEquals("size"u8)) { - if (Size != null) + if (property.Value.ValueKind == JsonValueKind.Null) { - content.Add(Size.Value.ToString(), "size"); + size = null; + continue; } + size = new GeneratedImageSize(property.Value.GetString()); + continue; } - if (Optional.IsDefined(EndUserId)) + if (property.NameEquals("user"u8)) { - content.Add(EndUserId, "user"); + user = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - return content; } + serializedAdditionalRawData = rawDataDictionary; + return new ImageVariationOptions( + image, + model, + n, + responseFormat, + size, + user, + serializedAdditionalRawData); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + return BinaryData.FromStream(stream); + } + else + { + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + } + } - switch (format) + internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + { + MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); + content.Add(Image, "image", "image"); + if (Optional.IsDefined(Model)) + { + if (Model != null) { - case "J": - return ModelReaderWriter.Write(this, options); - case "MFD": - return SerializeMultipart(options); - default: - throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support writing '{options.Format}' format."); + content.Add(Model.Value.ToString(), "model"); } } - - ImageVariationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (Optional.IsDefined(N)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (N != null) + { + content.Add(N.Value, "n"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + content.Add(ResponseFormat.Value.ToSerialString(), "response_format"); + } + } + if (Optional.IsDefined(Size)) + { + if (Size != null) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeImageVariationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support reading '{options.Format}' format."); + content.Add(Size.Value.ToString(), "size"); } } + if (Optional.IsDefined(EndUserId)) + { + content.Add(EndUserId, "user"); + } + return content; + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ImageVariationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeImageVariationOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support writing '{options.Format}' format."); } + } + + ImageVariationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeImageVariationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageVariationOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + internal static ImageVariationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeImageVariationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ImageVariationOptions.cs b/src/Generated/Models/ImageVariationOptions.cs index 6fac2f97..928f5bef 100644 --- a/src/Generated/Models/ImageVariationOptions.cs +++ b/src/Generated/Models/ImageVariationOptions.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Images +namespace OpenAI.Images; + +public partial class ImageVariationOptions { - public partial class ImageVariationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ImageVariationOptions(BinaryData image, InternalCreateImageVariationRequestModel? model, long? n, GeneratedImageFormat? responseFormat, GeneratedImageSize? size, string endUserId, IDictionary serializedAdditionalRawData) - { - Image = image; - Model = model; - N = n; - ResponseFormat = responseFormat; - Size = size; - EndUserId = endUserId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ImageVariationOptions(BinaryData image, InternalCreateImageVariationRequestModel? model, long? n, GeneratedImageFormat? responseFormat, GeneratedImageSize? size, string endUserId, IDictionary serializedAdditionalRawData) + { + Image = image; + Model = model; + N = n; + ResponseFormat = responseFormat; + Size = size; + EndUserId = endUserId; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAddUploadPartRequest.Serialization.cs b/src/Generated/Models/InternalAddUploadPartRequest.Serialization.cs index f76b44af..c4bd5b8c 100644 --- a/src/Generated/Models/InternalAddUploadPartRequest.Serialization.cs +++ b/src/Generated/Models/InternalAddUploadPartRequest.Serialization.cs @@ -9,157 +9,156 @@ using System.IO; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalAddUploadPartRequest : IJsonModel { - internal partial class InternalAddUploadPartRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("data") != true) - { - writer.WritePropertyName("data"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(global::System.BinaryData.FromStream(Data)); #else - using (JsonDocument document = JsonDocument.Parse(BinaryData.FromStream(Data))) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(BinaryData.FromStream(Data))) + { + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalAddUploadPartRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAddUploadPartRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAddUploadPartRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support reading '{format}' format."); } - internal static InternalAddUploadPartRequest DeserializeInternalAddUploadPartRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAddUploadPartRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - Stream data = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("data"u8)) - { - data = BinaryData.FromString(property.Value.GetRawText()).ToStream(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAddUploadPartRequest(data, serializedAdditionalRawData); - } + internal static InternalAddUploadPartRequest DeserializeInternalAddUploadPartRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); - using MemoryStream stream = new MemoryStream(); - content.WriteTo(stream); - if (stream.Position > int.MaxValue) + return null; + } + Stream data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("data"u8)) { - return BinaryData.FromStream(stream); + data = BinaryData.FromString(property.Value.GetRawText()).ToStream(); + continue; } - else + if (true) { - return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAddUploadPartRequest(data, serializedAdditionalRawData); + } - internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) { - MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); - content.Add(Data, "data", "data", "application/octet-stream"); - return content; + return BinaryData.FromStream(stream); } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + else { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - case "MFD": - return SerializeMultipart(options); - default: - throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support writing '{options.Format}' format."); - } + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); } + } - InternalAddUploadPartRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAddUploadPartRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support reading '{options.Format}' format."); - } - } + internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + { + MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); + content.Add(Data, "data", "data", "application/octet-stream"); + return content; + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalAddUploadPartRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAddUploadPartRequest(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support writing '{options.Format}' format."); } + } + + InternalAddUploadPartRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAddUploadPartRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAddUploadPartRequest)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + internal static InternalAddUploadPartRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAddUploadPartRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAddUploadPartRequest.cs b/src/Generated/Models/InternalAddUploadPartRequest.cs index f6035f34..f925f14f 100644 --- a/src/Generated/Models/InternalAddUploadPartRequest.cs +++ b/src/Generated/Models/InternalAddUploadPartRequest.cs @@ -6,28 +6,27 @@ using System.Collections.Generic; using System.IO; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalAddUploadPartRequest { - internal partial class InternalAddUploadPartRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalAddUploadPartRequest(Stream data) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalAddUploadPartRequest(Stream data) - { - Argument.AssertNotNull(data, nameof(data)); - - Data = data; - } + Argument.AssertNotNull(data, nameof(data)); - internal InternalAddUploadPartRequest(Stream data, IDictionary serializedAdditionalRawData) - { - Data = data; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Data = data; + } - internal InternalAddUploadPartRequest() - { - } + internal InternalAddUploadPartRequest(Stream data, IDictionary serializedAdditionalRawData) + { + Data = data; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public Stream Data { get; } + internal InternalAddUploadPartRequest() + { } -} + + public Stream Data { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantObjectObject.cs b/src/Generated/Models/InternalAssistantObjectObject.cs index bb627c2b..d27436fd 100644 --- a/src/Generated/Models/InternalAssistantObjectObject.cs +++ b/src/Generated/Models/InternalAssistantObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalAssistantObjectObject : IEquatable { - internal readonly partial struct InternalAssistantObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalAssistantObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalAssistantObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AssistantValue = "assistant"; + private const string AssistantValue = "assistant"; - public static InternalAssistantObjectObject Assistant { get; } = new InternalAssistantObjectObject(AssistantValue); - public static bool operator ==(InternalAssistantObjectObject left, InternalAssistantObjectObject right) => left.Equals(right); - public static bool operator !=(InternalAssistantObjectObject left, InternalAssistantObjectObject right) => !left.Equals(right); - public static implicit operator InternalAssistantObjectObject(string value) => new InternalAssistantObjectObject(value); + public static InternalAssistantObjectObject Assistant { get; } = new InternalAssistantObjectObject(AssistantValue); + public static bool operator ==(InternalAssistantObjectObject left, InternalAssistantObjectObject right) => left.Equals(right); + public static bool operator !=(InternalAssistantObjectObject left, InternalAssistantObjectObject right) => !left.Equals(right); + public static implicit operator InternalAssistantObjectObject(string value) => new InternalAssistantObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalAssistantObjectObject other && Equals(other); - public bool Equals(InternalAssistantObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAssistantObjectObject other && Equals(other); + public bool Equals(InternalAssistantObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantResponseFormatJsonObject.Serialization.cs b/src/Generated/Models/InternalAssistantResponseFormatJsonObject.Serialization.cs index 80afbf5f..6bbbde11 100644 --- a/src/Generated/Models/InternalAssistantResponseFormatJsonObject.Serialization.cs +++ b/src/Generated/Models/InternalAssistantResponseFormatJsonObject.Serialization.cs @@ -8,115 +8,114 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantResponseFormatJsonObject : IJsonModel { - internal partial class InternalAssistantResponseFormatJsonObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalAssistantResponseFormatJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAssistantResponseFormatJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAssistantResponseFormatJsonObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support reading '{format}' format."); } - internal static InternalAssistantResponseFormatJsonObject DeserializeInternalAssistantResponseFormatJsonObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantResponseFormatJsonObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalAssistantResponseFormatJsonObject DeserializeInternalAssistantResponseFormatJsonObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetString(); + continue; } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (true) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAssistantResponseFormatJsonObject(type, serializedAdditionalRawData); } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantResponseFormatJsonObject(type, serializedAdditionalRawData); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support writing '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support writing '{options.Format}' format."); } + } - InternalAssistantResponseFormatJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAssistantResponseFormatJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAssistantResponseFormatJsonObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantResponseFormatJsonObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonObject)} does not support reading '{options.Format}' format."); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantResponseFormatJsonObject.cs b/src/Generated/Models/InternalAssistantResponseFormatJsonObject.cs index 96c7e52e..f57d62e0 100644 --- a/src/Generated/Models/InternalAssistantResponseFormatJsonObject.cs +++ b/src/Generated/Models/InternalAssistantResponseFormatJsonObject.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantResponseFormatJsonObject : AssistantResponseFormat { - internal partial class InternalAssistantResponseFormatJsonObject : AssistantResponseFormat + public InternalAssistantResponseFormatJsonObject() { - public InternalAssistantResponseFormatJsonObject() - { - Type = "json_object"; - } + Type = "json_object"; + } - internal InternalAssistantResponseFormatJsonObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalAssistantResponseFormatJsonObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.Serialization.cs b/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.Serialization.cs index 24865dbf..fe6a2733 100644 --- a/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.Serialization.cs +++ b/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.Serialization.cs @@ -9,126 +9,125 @@ using System.Text.Json; using OpenAI.Internal; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantResponseFormatJsonSchema : IJsonModel { - internal partial class InternalAssistantResponseFormatJsonSchema : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("json_schema") != true) - { - writer.WritePropertyName("json_schema"u8); - writer.WriteObjectValue(JsonSchema, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("json_schema") != true) + { + writer.WritePropertyName("json_schema"u8); + writer.WriteObjectValue(JsonSchema, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalAssistantResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAssistantResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAssistantResponseFormatJsonSchema(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support reading '{format}' format."); } - internal static InternalAssistantResponseFormatJsonSchema DeserializeInternalAssistantResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantResponseFormatJsonSchema(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalAssistantResponseFormatJsonSchema DeserializeInternalAssistantResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponseFormatJsonSchemaJsonSchema jsonSchema = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("json_schema"u8)) { - return null; + jsonSchema = InternalResponseFormatJsonSchemaJsonSchema.DeserializeInternalResponseFormatJsonSchemaJsonSchema(property.Value, options); + continue; } - InternalResponseFormatJsonSchemaJsonSchema jsonSchema = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("json_schema"u8)) - { - jsonSchema = InternalResponseFormatJsonSchemaJsonSchema.DeserializeInternalResponseFormatJsonSchemaJsonSchema(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAssistantResponseFormatJsonSchema(type, serializedAdditionalRawData, jsonSchema); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantResponseFormatJsonSchema(type, serializedAdditionalRawData, jsonSchema); + } - InternalAssistantResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAssistantResponseFormatJsonSchema(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalAssistantResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantResponseFormatJsonSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatJsonSchema)} does not support reading '{options.Format}' format."); + } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.cs b/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.cs index 68db77ff..1d789693 100644 --- a/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.cs +++ b/src/Generated/Models/InternalAssistantResponseFormatJsonSchema.cs @@ -6,27 +6,26 @@ using System.Collections.Generic; using OpenAI.Internal; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantResponseFormatJsonSchema : AssistantResponseFormat { - internal partial class InternalAssistantResponseFormatJsonSchema : AssistantResponseFormat + public InternalAssistantResponseFormatJsonSchema(InternalResponseFormatJsonSchemaJsonSchema jsonSchema) { - public InternalAssistantResponseFormatJsonSchema(InternalResponseFormatJsonSchemaJsonSchema jsonSchema) - { - Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); - - Type = "json_schema"; - JsonSchema = jsonSchema; - } + Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); - internal InternalAssistantResponseFormatJsonSchema(string type, IDictionary serializedAdditionalRawData, InternalResponseFormatJsonSchemaJsonSchema jsonSchema) : base(type, serializedAdditionalRawData) - { - JsonSchema = jsonSchema; - } + Type = "json_schema"; + JsonSchema = jsonSchema; + } - internal InternalAssistantResponseFormatJsonSchema() - { - } + internal InternalAssistantResponseFormatJsonSchema(string type, IDictionary serializedAdditionalRawData, InternalResponseFormatJsonSchemaJsonSchema jsonSchema) : base(type, serializedAdditionalRawData) + { + JsonSchema = jsonSchema; + } - public InternalResponseFormatJsonSchemaJsonSchema JsonSchema { get; } + internal InternalAssistantResponseFormatJsonSchema() + { } -} + + public InternalResponseFormatJsonSchemaJsonSchema JsonSchema { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantResponseFormatText.Serialization.cs b/src/Generated/Models/InternalAssistantResponseFormatText.Serialization.cs index a2ae06ee..57240e90 100644 --- a/src/Generated/Models/InternalAssistantResponseFormatText.Serialization.cs +++ b/src/Generated/Models/InternalAssistantResponseFormatText.Serialization.cs @@ -8,115 +8,114 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantResponseFormatText : IJsonModel { - internal partial class InternalAssistantResponseFormatText : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalAssistantResponseFormatText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAssistantResponseFormatText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAssistantResponseFormatText(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support reading '{format}' format."); } - internal static InternalAssistantResponseFormatText DeserializeInternalAssistantResponseFormatText(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantResponseFormatText(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalAssistantResponseFormatText DeserializeInternalAssistantResponseFormatText(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetString(); + continue; } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (true) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAssistantResponseFormatText(type, serializedAdditionalRawData); } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantResponseFormatText(type, serializedAdditionalRawData); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support writing '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support writing '{options.Format}' format."); } + } - InternalAssistantResponseFormatText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAssistantResponseFormatText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAssistantResponseFormatText(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantResponseFormatText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantResponseFormatText)} does not support reading '{options.Format}' format."); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantResponseFormatText.cs b/src/Generated/Models/InternalAssistantResponseFormatText.cs index e2763f14..0f656891 100644 --- a/src/Generated/Models/InternalAssistantResponseFormatText.cs +++ b/src/Generated/Models/InternalAssistantResponseFormatText.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantResponseFormatText : AssistantResponseFormat { - internal partial class InternalAssistantResponseFormatText : AssistantResponseFormat + public InternalAssistantResponseFormatText() { - public InternalAssistantResponseFormatText() - { - Type = "text"; - } + Type = "text"; + } - internal InternalAssistantResponseFormatText(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalAssistantResponseFormatText(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.Serialization.cs b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.Serialization.cs index 7a833860..925b1006 100644 --- a/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.Serialization.cs +++ b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantToolsFileSearchFileSearch : IJsonModel { - internal partial class InternalAssistantToolsFileSearchFileSearch : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("max_num_results") != true && Optional.IsDefined(InternalMaxNumResults)) - { - writer.WritePropertyName("max_num_results"u8); - writer.WriteNumberValue(InternalMaxNumResults.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("ranking_options") != true && Optional.IsDefined(RankingOptions)) - { - writer.WritePropertyName("ranking_options"u8); - writer.WriteObjectValue(RankingOptions, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("max_num_results") != true && Optional.IsDefined(InternalMaxNumResults)) + { + writer.WritePropertyName("max_num_results"u8); + writer.WriteNumberValue(InternalMaxNumResults.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("ranking_options") != true && Optional.IsDefined(RankingOptions)) + { + writer.WritePropertyName("ranking_options"u8); + writer.WriteObjectValue(RankingOptions, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalAssistantToolsFileSearchFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAssistantToolsFileSearchFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support reading '{format}' format."); } - internal static InternalAssistantToolsFileSearchFileSearch DeserializeInternalAssistantToolsFileSearchFileSearch(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int? maxNumResults = default; - FileSearchRankingOptions rankingOptions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalAssistantToolsFileSearchFileSearch DeserializeInternalAssistantToolsFileSearchFileSearch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxNumResults = default; + FileSearchRankingOptions rankingOptions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_num_results"u8)) { - if (property.NameEquals("max_num_results"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxNumResults = property.Value.GetInt32(); continue; } - if (property.NameEquals("ranking_options"u8)) + maxNumResults = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("ranking_options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAssistantToolsFileSearchFileSearch(maxNumResults, rankingOptions, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantToolsFileSearchFileSearch(maxNumResults, rankingOptions, serializedAdditionalRawData); + } - InternalAssistantToolsFileSearchFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalAssistantToolsFileSearchFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalAssistantToolsFileSearchFileSearch FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchFileSearch)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalAssistantToolsFileSearchFileSearch FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAssistantToolsFileSearchFileSearch(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.cs b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.cs index 6da7606a..d893cda0 100644 --- a/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.cs +++ b/src/Generated/Models/InternalAssistantToolsFileSearchFileSearch.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantToolsFileSearchFileSearch { - internal partial class InternalAssistantToolsFileSearchFileSearch + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalAssistantToolsFileSearchFileSearch() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalAssistantToolsFileSearchFileSearch() - { - } + } - internal InternalAssistantToolsFileSearchFileSearch(int? internalMaxNumResults, FileSearchRankingOptions rankingOptions, IDictionary serializedAdditionalRawData) - { - InternalMaxNumResults = internalMaxNumResults; - RankingOptions = rankingOptions; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public FileSearchRankingOptions RankingOptions { get; set; } + internal InternalAssistantToolsFileSearchFileSearch(int? internalMaxNumResults, FileSearchRankingOptions rankingOptions, IDictionary serializedAdditionalRawData) + { + InternalMaxNumResults = internalMaxNumResults; + RankingOptions = rankingOptions; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public FileSearchRankingOptions RankingOptions { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.Serialization.cs b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.Serialization.cs index ef306bf2..ad042649 100644 --- a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.Serialization.cs +++ b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantToolsFileSearchTypeOnly : IJsonModel { - internal partial class InternalAssistantToolsFileSearchTypeOnly : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support writing '{format}' format."); } - InternalAssistantToolsFileSearchTypeOnly IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); } - - internal static InternalAssistantToolsFileSearchTypeOnly DeserializeInternalAssistantToolsFileSearchTypeOnly(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalAssistantToolsFileSearchTypeOnlyType type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = new InternalAssistantToolsFileSearchTypeOnlyType(property.Value.GetString()); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAssistantToolsFileSearchTypeOnly(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalAssistantToolsFileSearchTypeOnly IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support reading '{format}' format."); } - InternalAssistantToolsFileSearchTypeOnly IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement, options); + } + + internal static InternalAssistantToolsFileSearchTypeOnly DeserializeInternalAssistantToolsFileSearchTypeOnly(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalAssistantToolsFileSearchTypeOnlyType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support reading '{options.Format}' format."); + type = new InternalAssistantToolsFileSearchTypeOnlyType(property.Value.GetString()); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantToolsFileSearchTypeOnly(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalAssistantToolsFileSearchTypeOnly FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support writing '{options.Format}' format."); } + } + + InternalAssistantToolsFileSearchTypeOnly IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantToolsFileSearchTypeOnly)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalAssistantToolsFileSearchTypeOnly FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAssistantToolsFileSearchTypeOnly(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.cs b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.cs index 607f7fb4..dce05150 100644 --- a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.cs +++ b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnly.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantToolsFileSearchTypeOnly { - internal partial class InternalAssistantToolsFileSearchTypeOnly + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalAssistantToolsFileSearchTypeOnly() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalAssistantToolsFileSearchTypeOnly() - { - } - - internal InternalAssistantToolsFileSearchTypeOnly(InternalAssistantToolsFileSearchTypeOnlyType type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalAssistantToolsFileSearchTypeOnlyType Type { get; } = InternalAssistantToolsFileSearchTypeOnlyType.FileSearch; + internal InternalAssistantToolsFileSearchTypeOnly(InternalAssistantToolsFileSearchTypeOnlyType type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalAssistantToolsFileSearchTypeOnlyType Type { get; } = InternalAssistantToolsFileSearchTypeOnlyType.FileSearch; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnlyType.cs b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnlyType.cs index c1378a9a..b439b69c 100644 --- a/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnlyType.cs +++ b/src/Generated/Models/InternalAssistantToolsFileSearchTypeOnlyType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalAssistantToolsFileSearchTypeOnlyType : IEquatable { - internal readonly partial struct InternalAssistantToolsFileSearchTypeOnlyType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalAssistantToolsFileSearchTypeOnlyType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalAssistantToolsFileSearchTypeOnlyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FileSearchValue = "file_search"; + private const string FileSearchValue = "file_search"; - public static InternalAssistantToolsFileSearchTypeOnlyType FileSearch { get; } = new InternalAssistantToolsFileSearchTypeOnlyType(FileSearchValue); - public static bool operator ==(InternalAssistantToolsFileSearchTypeOnlyType left, InternalAssistantToolsFileSearchTypeOnlyType right) => left.Equals(right); - public static bool operator !=(InternalAssistantToolsFileSearchTypeOnlyType left, InternalAssistantToolsFileSearchTypeOnlyType right) => !left.Equals(right); - public static implicit operator InternalAssistantToolsFileSearchTypeOnlyType(string value) => new InternalAssistantToolsFileSearchTypeOnlyType(value); + public static InternalAssistantToolsFileSearchTypeOnlyType FileSearch { get; } = new InternalAssistantToolsFileSearchTypeOnlyType(FileSearchValue); + public static bool operator ==(InternalAssistantToolsFileSearchTypeOnlyType left, InternalAssistantToolsFileSearchTypeOnlyType right) => left.Equals(right); + public static bool operator !=(InternalAssistantToolsFileSearchTypeOnlyType left, InternalAssistantToolsFileSearchTypeOnlyType right) => !left.Equals(right); + public static implicit operator InternalAssistantToolsFileSearchTypeOnlyType(string value) => new InternalAssistantToolsFileSearchTypeOnlyType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalAssistantToolsFileSearchTypeOnlyType other && Equals(other); - public bool Equals(InternalAssistantToolsFileSearchTypeOnlyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAssistantToolsFileSearchTypeOnlyType other && Equals(other); + public bool Equals(InternalAssistantToolsFileSearchTypeOnlyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.Serialization.cs b/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.Serialization.cs index 0ef83db2..b6335654 100644 --- a/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.Serialization.cs +++ b/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantsNamedToolChoiceFunction : IJsonModel { - internal partial class InternalAssistantsNamedToolChoiceFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support writing '{format}' format."); } - InternalAssistantsNamedToolChoiceFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAssistantsNamedToolChoiceFunction(document.RootElement, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - internal static InternalAssistantsNamedToolChoiceFunction DeserializeInternalAssistantsNamedToolChoiceFunction(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("name"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - name = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAssistantsNamedToolChoiceFunction(name, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalAssistantsNamedToolChoiceFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support reading '{format}' format."); } - InternalAssistantsNamedToolChoiceFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAssistantsNamedToolChoiceFunction(document.RootElement, options); + } + + internal static InternalAssistantsNamedToolChoiceFunction DeserializeInternalAssistantsNamedToolChoiceFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAssistantsNamedToolChoiceFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support reading '{options.Format}' format."); + name = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAssistantsNamedToolChoiceFunction(name, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalAssistantsNamedToolChoiceFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAssistantsNamedToolChoiceFunction(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support writing '{options.Format}' format."); } + } + + InternalAssistantsNamedToolChoiceFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAssistantsNamedToolChoiceFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAssistantsNamedToolChoiceFunction)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalAssistantsNamedToolChoiceFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAssistantsNamedToolChoiceFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.cs b/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.cs index 88e7c6d1..7efccaeb 100644 --- a/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.cs +++ b/src/Generated/Models/InternalAssistantsNamedToolChoiceFunction.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalAssistantsNamedToolChoiceFunction { - internal partial class InternalAssistantsNamedToolChoiceFunction + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalAssistantsNamedToolChoiceFunction(string name) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalAssistantsNamedToolChoiceFunction(string name) - { - Argument.AssertNotNull(name, nameof(name)); - - Name = name; - } + Argument.AssertNotNull(name, nameof(name)); - internal InternalAssistantsNamedToolChoiceFunction(string name, IDictionary serializedAdditionalRawData) - { - Name = name; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Name = name; + } - internal InternalAssistantsNamedToolChoiceFunction() - { - } + internal InternalAssistantsNamedToolChoiceFunction(string name, IDictionary serializedAdditionalRawData) + { + Name = name; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string Name { get; set; } + internal InternalAssistantsNamedToolChoiceFunction() + { } -} + + public string Name { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAssistantsNamedToolChoiceType.cs b/src/Generated/Models/InternalAssistantsNamedToolChoiceType.cs index a71bdc9a..6693a48d 100644 --- a/src/Generated/Models/InternalAssistantsNamedToolChoiceType.cs +++ b/src/Generated/Models/InternalAssistantsNamedToolChoiceType.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalAssistantsNamedToolChoiceType : IEquatable { - internal readonly partial struct InternalAssistantsNamedToolChoiceType : IEquatable + private readonly string _value; + + public InternalAssistantsNamedToolChoiceType(string value) { - private readonly string _value; - - public InternalAssistantsNamedToolChoiceType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string FunctionValue = "function"; - private const string CodeInterpreterValue = "code_interpreter"; - private const string FileSearchValue = "file_search"; - - public static InternalAssistantsNamedToolChoiceType Function { get; } = new InternalAssistantsNamedToolChoiceType(FunctionValue); - public static InternalAssistantsNamedToolChoiceType CodeInterpreter { get; } = new InternalAssistantsNamedToolChoiceType(CodeInterpreterValue); - public static InternalAssistantsNamedToolChoiceType FileSearch { get; } = new InternalAssistantsNamedToolChoiceType(FileSearchValue); - public static bool operator ==(InternalAssistantsNamedToolChoiceType left, InternalAssistantsNamedToolChoiceType right) => left.Equals(right); - public static bool operator !=(InternalAssistantsNamedToolChoiceType left, InternalAssistantsNamedToolChoiceType right) => !left.Equals(right); - public static implicit operator InternalAssistantsNamedToolChoiceType(string value) => new InternalAssistantsNamedToolChoiceType(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalAssistantsNamedToolChoiceType other && Equals(other); - public bool Equals(InternalAssistantsNamedToolChoiceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string FunctionValue = "function"; + private const string CodeInterpreterValue = "code_interpreter"; + private const string FileSearchValue = "file_search"; + + public static InternalAssistantsNamedToolChoiceType Function { get; } = new InternalAssistantsNamedToolChoiceType(FunctionValue); + public static InternalAssistantsNamedToolChoiceType CodeInterpreter { get; } = new InternalAssistantsNamedToolChoiceType(CodeInterpreterValue); + public static InternalAssistantsNamedToolChoiceType FileSearch { get; } = new InternalAssistantsNamedToolChoiceType(FileSearchValue); + public static bool operator ==(InternalAssistantsNamedToolChoiceType left, InternalAssistantsNamedToolChoiceType right) => left.Equals(right); + public static bool operator !=(InternalAssistantsNamedToolChoiceType left, InternalAssistantsNamedToolChoiceType right) => !left.Equals(right); + public static implicit operator InternalAssistantsNamedToolChoiceType(string value) => new InternalAssistantsNamedToolChoiceType(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAssistantsNamedToolChoiceType other && Equals(other); + public bool Equals(InternalAssistantsNamedToolChoiceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAutoChunkingStrategy.Serialization.cs b/src/Generated/Models/InternalAutoChunkingStrategy.Serialization.cs index 3f1028c9..40ac0394 100644 --- a/src/Generated/Models/InternalAutoChunkingStrategy.Serialization.cs +++ b/src/Generated/Models/InternalAutoChunkingStrategy.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalAutoChunkingStrategy : IJsonModel { - internal partial class InternalAutoChunkingStrategy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support writing '{format}' format."); } - InternalAutoChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAutoChunkingStrategy(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalAutoChunkingStrategy DeserializeInternalAutoChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAutoChunkingStrategy(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalAutoChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support reading '{format}' format."); } - InternalAutoChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAutoChunkingStrategy(document.RootElement, options); + } + + internal static InternalAutoChunkingStrategy DeserializeInternalAutoChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAutoChunkingStrategy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAutoChunkingStrategy(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalAutoChunkingStrategy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAutoChunkingStrategy(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support writing '{options.Format}' format."); } + } + + InternalAutoChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAutoChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategy)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalAutoChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAutoChunkingStrategy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAutoChunkingStrategy.cs b/src/Generated/Models/InternalAutoChunkingStrategy.cs index 09a13282..014f4c7f 100644 --- a/src/Generated/Models/InternalAutoChunkingStrategy.cs +++ b/src/Generated/Models/InternalAutoChunkingStrategy.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalAutoChunkingStrategy : FileChunkingStrategy { - internal partial class InternalAutoChunkingStrategy : FileChunkingStrategy + public InternalAutoChunkingStrategy() { - public InternalAutoChunkingStrategy() - { - Type = "auto"; - } + Type = "auto"; + } - internal InternalAutoChunkingStrategy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalAutoChunkingStrategy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.Serialization.cs b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.Serialization.cs index ba2aafda..37a74ad4 100644 --- a/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.Serialization.cs +++ b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalAutoChunkingStrategyRequestParam : IJsonModel { - internal partial class InternalAutoChunkingStrategyRequestParam : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support writing '{format}' format."); } - InternalAutoChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalAutoChunkingStrategyRequestParam DeserializeInternalAutoChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAutoChunkingStrategyRequestParam(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalAutoChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support reading '{format}' format."); } - InternalAutoChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement, options); + } + + internal static InternalAutoChunkingStrategyRequestParam DeserializeInternalAutoChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalAutoChunkingStrategyRequestParam(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalAutoChunkingStrategyRequestParam FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); } + } + + InternalAutoChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAutoChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalAutoChunkingStrategyRequestParam FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalAutoChunkingStrategyRequestParam(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.cs b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.cs index 3b429d3e..5ce34146 100644 --- a/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.cs +++ b/src/Generated/Models/InternalAutoChunkingStrategyRequestParam.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalAutoChunkingStrategyRequestParam : InternalFileChunkingStrategyRequestParam { - internal partial class InternalAutoChunkingStrategyRequestParam : InternalFileChunkingStrategyRequestParam + public InternalAutoChunkingStrategyRequestParam() { - public InternalAutoChunkingStrategyRequestParam() - { - Type = "auto"; - } + Type = "auto"; + } - internal InternalAutoChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalAutoChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchCompletionTimeframe.cs b/src/Generated/Models/InternalBatchCompletionTimeframe.cs index 836a9c1e..705dacc1 100644 --- a/src/Generated/Models/InternalBatchCompletionTimeframe.cs +++ b/src/Generated/Models/InternalBatchCompletionTimeframe.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal readonly partial struct InternalBatchCompletionTimeframe : IEquatable { - internal readonly partial struct InternalBatchCompletionTimeframe : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalBatchCompletionTimeframe(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalBatchCompletionTimeframe(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string _24hValue = "24h"; + private const string _24hValue = "24h"; - public static InternalBatchCompletionTimeframe _24h { get; } = new InternalBatchCompletionTimeframe(_24hValue); - public static bool operator ==(InternalBatchCompletionTimeframe left, InternalBatchCompletionTimeframe right) => left.Equals(right); - public static bool operator !=(InternalBatchCompletionTimeframe left, InternalBatchCompletionTimeframe right) => !left.Equals(right); - public static implicit operator InternalBatchCompletionTimeframe(string value) => new InternalBatchCompletionTimeframe(value); + public static InternalBatchCompletionTimeframe _24h { get; } = new InternalBatchCompletionTimeframe(_24hValue); + public static bool operator ==(InternalBatchCompletionTimeframe left, InternalBatchCompletionTimeframe right) => left.Equals(right); + public static bool operator !=(InternalBatchCompletionTimeframe left, InternalBatchCompletionTimeframe right) => !left.Equals(right); + public static implicit operator InternalBatchCompletionTimeframe(string value) => new InternalBatchCompletionTimeframe(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalBatchCompletionTimeframe other && Equals(other); - public bool Equals(InternalBatchCompletionTimeframe other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalBatchCompletionTimeframe other && Equals(other); + public bool Equals(InternalBatchCompletionTimeframe other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchError.Serialization.cs b/src/Generated/Models/InternalBatchError.Serialization.cs index 0e768f6a..a5e33d01 100644 --- a/src/Generated/Models/InternalBatchError.Serialization.cs +++ b/src/Generated/Models/InternalBatchError.Serialization.cs @@ -8,183 +8,182 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchError : IJsonModel { - internal partial class InternalBatchError : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchError)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchError)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData?.ContainsKey("param") != true && Optional.IsDefined(Param)) + { + if (Param != null) { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code); + writer.WritePropertyName("param"u8); + writer.WriteStringValue(Param); } - if (SerializedAdditionalRawData?.ContainsKey("message") != true && Optional.IsDefined(Message)) + else { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); + writer.WriteNull("param"); } - if (SerializedAdditionalRawData?.ContainsKey("param") != true && Optional.IsDefined(Param)) + } + if (SerializedAdditionalRawData?.ContainsKey("line") != true && Optional.IsDefined(Line)) + { + if (Line != null) { - if (Param != null) - { - writer.WritePropertyName("param"u8); - writer.WriteStringValue(Param); - } - else - { - writer.WriteNull("param"); - } + writer.WritePropertyName("line"u8); + writer.WriteNumberValue(Line.Value); } - if (SerializedAdditionalRawData?.ContainsKey("line") != true && Optional.IsDefined(Line)) + else { - if (Line != null) - { - writer.WritePropertyName("line"u8); - writer.WriteNumberValue(Line.Value); - } - else - { - writer.WriteNull("line"); - } + writer.WriteNull("line"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalBatchError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalBatchError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchError(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalBatchError)} does not support reading '{format}' format."); } - internal static InternalBatchError DeserializeInternalBatchError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchError(document.RootElement, options); + } + + internal static InternalBatchError DeserializeInternalBatchError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + string param = default; + int? line = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) { - return null; + code = property.Value.GetString(); + continue; } - string code = default; - string message = default; - string param = default; - int? line = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("message"u8)) { - if (property.NameEquals("code"u8)) - { - code = property.Value.GetString(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (property.NameEquals("param"u8)) + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("param"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - param = null; - continue; - } - param = property.Value.GetString(); + param = null; continue; } - if (property.NameEquals("line"u8)) + param = property.Value.GetString(); + continue; + } + if (property.NameEquals("line"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - line = null; - continue; - } - line = property.Value.GetInt32(); + line = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + line = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchError(code, message, param, line, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchError)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchError(code, message, param, line, serializedAdditionalRawData); + } - InternalBatchError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchError)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchError)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalBatchError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchError FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchError(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchError)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchError FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchError(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchError.cs b/src/Generated/Models/InternalBatchError.cs index 411b48c4..1069c909 100644 --- a/src/Generated/Models/InternalBatchError.cs +++ b/src/Generated/Models/InternalBatchError.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchError { - internal partial class InternalBatchError + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalBatchError() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalBatchError() - { - } - - internal InternalBatchError(string code, string message, string param, int? line, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - Param = param; - Line = line; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string Code { get; } - public string Message { get; } - public string Param { get; } - public int? Line { get; } + internal InternalBatchError(string code, string message, string param, int? line, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + Param = param; + Line = line; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Code { get; } + public string Message { get; } + public string Param { get; } + public int? Line { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchErrors.Serialization.cs b/src/Generated/Models/InternalBatchErrors.Serialization.cs index d75c78a0..5602a2e6 100644 --- a/src/Generated/Models/InternalBatchErrors.Serialization.cs +++ b/src/Generated/Models/InternalBatchErrors.Serialization.cs @@ -8,155 +8,154 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchErrors : IJsonModel { - internal partial class InternalBatchErrors : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true && Optional.IsDefined(Object)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true && Optional.IsDefined(Object)) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.Value.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true && Optional.IsCollectionDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.Value.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true && Optional.IsCollectionDefined(Data)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalBatchErrors IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalBatchErrors IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchErrors(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support reading '{format}' format."); } - internal static InternalBatchErrors DeserializeInternalBatchErrors(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchErrors(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalBatchErrorsObject? @object = default; - IReadOnlyList data = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalBatchErrors DeserializeInternalBatchErrors(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalBatchErrorsObject? @object = default; + IReadOnlyList data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - if (property.NameEquals("object"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - @object = new InternalBatchErrorsObject(property.Value.GetString()); continue; } - if (property.NameEquals("data"u8)) + @object = new InternalBatchErrorsObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalBatchError.DeserializeInternalBatchError(item, options)); - } - data = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalBatchError.DeserializeInternalBatchError(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchErrors(@object, data ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchErrors(@object, data ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalBatchErrors IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchErrors(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalBatchErrors IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchErrors FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchErrors(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchErrors(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchErrors)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchErrors FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchErrors(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchErrors.cs b/src/Generated/Models/InternalBatchErrors.cs index ef20e9e0..eeb2ee5f 100644 --- a/src/Generated/Models/InternalBatchErrors.cs +++ b/src/Generated/Models/InternalBatchErrors.cs @@ -5,24 +5,23 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchErrors { - internal partial class InternalBatchErrors + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalBatchErrors() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalBatchErrors() - { - Data = new ChangeTrackingList(); - } - - internal InternalBatchErrors(InternalBatchErrorsObject? @object, IReadOnlyList data, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Data = new ChangeTrackingList(); + } - public InternalBatchErrorsObject? Object { get; } - public IReadOnlyList Data { get; } + internal InternalBatchErrors(InternalBatchErrorsObject? @object, IReadOnlyList data, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalBatchErrorsObject? Object { get; } + public IReadOnlyList Data { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchErrorsObject.cs b/src/Generated/Models/InternalBatchErrorsObject.cs index 0f98bd40..b8ecd803 100644 --- a/src/Generated/Models/InternalBatchErrorsObject.cs +++ b/src/Generated/Models/InternalBatchErrorsObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal readonly partial struct InternalBatchErrorsObject : IEquatable { - internal readonly partial struct InternalBatchErrorsObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalBatchErrorsObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalBatchErrorsObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalBatchErrorsObject List { get; } = new InternalBatchErrorsObject(ListValue); - public static bool operator ==(InternalBatchErrorsObject left, InternalBatchErrorsObject right) => left.Equals(right); - public static bool operator !=(InternalBatchErrorsObject left, InternalBatchErrorsObject right) => !left.Equals(right); - public static implicit operator InternalBatchErrorsObject(string value) => new InternalBatchErrorsObject(value); + public static InternalBatchErrorsObject List { get; } = new InternalBatchErrorsObject(ListValue); + public static bool operator ==(InternalBatchErrorsObject left, InternalBatchErrorsObject right) => left.Equals(right); + public static bool operator !=(InternalBatchErrorsObject left, InternalBatchErrorsObject right) => !left.Equals(right); + public static implicit operator InternalBatchErrorsObject(string value) => new InternalBatchErrorsObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalBatchErrorsObject other && Equals(other); - public bool Equals(InternalBatchErrorsObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalBatchErrorsObject other && Equals(other); + public bool Equals(InternalBatchErrorsObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchJob.Serialization.cs b/src/Generated/Models/InternalBatchJob.Serialization.cs index f0aa4f8f..0bae3261 100644 --- a/src/Generated/Models/InternalBatchJob.Serialization.cs +++ b/src/Generated/Models/InternalBatchJob.Serialization.cs @@ -8,418 +8,417 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchJob : IJsonModel { - internal partial class InternalBatchJob : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchJob)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchJob)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) - { - writer.WritePropertyName("endpoint"u8); - writer.WriteStringValue(Endpoint); - } - if (SerializedAdditionalRawData?.ContainsKey("errors") != true && Optional.IsDefined(Errors)) - { - writer.WritePropertyName("errors"u8); - writer.WriteObjectValue(Errors, options); - } - if (SerializedAdditionalRawData?.ContainsKey("input_file_id") != true) - { - writer.WritePropertyName("input_file_id"u8); - writer.WriteStringValue(InputFileId); - } - if (SerializedAdditionalRawData?.ContainsKey("completion_window") != true) - { - writer.WritePropertyName("completion_window"u8); - writer.WriteStringValue(CompletionWindow); - } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) + { + writer.WritePropertyName("endpoint"u8); + writer.WriteStringValue(Endpoint); + } + if (SerializedAdditionalRawData?.ContainsKey("errors") != true && Optional.IsDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteObjectValue(Errors, options); + } + if (SerializedAdditionalRawData?.ContainsKey("input_file_id") != true) + { + writer.WritePropertyName("input_file_id"u8); + writer.WriteStringValue(InputFileId); + } + if (SerializedAdditionalRawData?.ContainsKey("completion_window") != true) + { + writer.WritePropertyName("completion_window"u8); + writer.WriteStringValue(CompletionWindow); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("output_file_id") != true && Optional.IsDefined(OutputFileId)) + { + writer.WritePropertyName("output_file_id"u8); + writer.WriteStringValue(OutputFileId); + } + if (SerializedAdditionalRawData?.ContainsKey("error_file_id") != true && Optional.IsDefined(ErrorFileId)) + { + writer.WritePropertyName("error_file_id"u8); + writer.WriteStringValue(ErrorFileId); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("in_progress_at") != true && Optional.IsDefined(InProgressAt)) + { + writer.WritePropertyName("in_progress_at"u8); + writer.WriteNumberValue(InProgressAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true && Optional.IsDefined(ExpiresAt)) + { + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("finalizing_at") != true && Optional.IsDefined(FinalizingAt)) + { + writer.WritePropertyName("finalizing_at"u8); + writer.WriteNumberValue(FinalizingAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true && Optional.IsDefined(CompletedAt)) + { + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("failed_at") != true && Optional.IsDefined(FailedAt)) + { + writer.WritePropertyName("failed_at"u8); + writer.WriteNumberValue(FailedAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("expired_at") != true && Optional.IsDefined(ExpiredAt)) + { + writer.WritePropertyName("expired_at"u8); + writer.WriteNumberValue(ExpiredAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("cancelling_at") != true && Optional.IsDefined(CancellingAt)) + { + writer.WritePropertyName("cancelling_at"u8); + writer.WriteNumberValue(CancellingAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("cancelled_at") != true && Optional.IsDefined(CancelledAt)) + { + writer.WritePropertyName("cancelled_at"u8); + writer.WriteNumberValue(CancelledAt.Value, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("request_counts") != true && Optional.IsDefined(RequestCounts)) + { + writer.WritePropertyName("request_counts"u8); + writer.WriteObjectValue(RequestCounts, options); + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("output_file_id") != true && Optional.IsDefined(OutputFileId)) + else { - writer.WritePropertyName("output_file_id"u8); - writer.WriteStringValue(OutputFileId); + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("error_file_id") != true && Optional.IsDefined(ErrorFileId)) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("error_file_id"u8); - writer.WriteStringValue(ErrorFileId); + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + } + writer.WriteEndObject(); + } + + InternalBatchJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalBatchJob)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchJob(document.RootElement, options); + } + + internal static InternalBatchJob DeserializeInternalBatchJob(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalBatchObject @object = default; + string endpoint = default; + InternalBatchErrors errors = default; + string inputFileId = default; + string completionWindow = default; + InternalBatchStatus status = default; + string outputFileId = default; + string errorFileId = default; + DateTimeOffset createdAt = default; + DateTimeOffset? inProgressAt = default; + DateTimeOffset? expiresAt = default; + DateTimeOffset? finalizingAt = default; + DateTimeOffset? completedAt = default; + DateTimeOffset? failedAt = default; + DateTimeOffset? expiredAt = default; + DateTimeOffset? cancellingAt = default; + DateTimeOffset? cancelledAt = default; + InternalBatchRequestCounts requestCounts = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + id = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("in_progress_at") != true && Optional.IsDefined(InProgressAt)) + if (property.NameEquals("object"u8)) { - writer.WritePropertyName("in_progress_at"u8); - writer.WriteNumberValue(InProgressAt.Value, "U"); + @object = new InternalBatchObject(property.Value.GetString()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true && Optional.IsDefined(ExpiresAt)) + if (property.NameEquals("endpoint"u8)) { - writer.WritePropertyName("expires_at"u8); - writer.WriteNumberValue(ExpiresAt.Value, "U"); + endpoint = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("finalizing_at") != true && Optional.IsDefined(FinalizingAt)) + if (property.NameEquals("errors"u8)) { - writer.WritePropertyName("finalizing_at"u8); - writer.WriteNumberValue(FinalizingAt.Value, "U"); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errors = InternalBatchErrors.DeserializeInternalBatchErrors(property.Value, options); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true && Optional.IsDefined(CompletedAt)) + if (property.NameEquals("input_file_id"u8)) { - writer.WritePropertyName("completed_at"u8); - writer.WriteNumberValue(CompletedAt.Value, "U"); + inputFileId = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("failed_at") != true && Optional.IsDefined(FailedAt)) + if (property.NameEquals("completion_window"u8)) { - writer.WritePropertyName("failed_at"u8); - writer.WriteNumberValue(FailedAt.Value, "U"); + completionWindow = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("expired_at") != true && Optional.IsDefined(ExpiredAt)) + if (property.NameEquals("status"u8)) { - writer.WritePropertyName("expired_at"u8); - writer.WriteNumberValue(ExpiredAt.Value, "U"); + status = new InternalBatchStatus(property.Value.GetString()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("cancelling_at") != true && Optional.IsDefined(CancellingAt)) + if (property.NameEquals("output_file_id"u8)) { - writer.WritePropertyName("cancelling_at"u8); - writer.WriteNumberValue(CancellingAt.Value, "U"); + outputFileId = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("cancelled_at") != true && Optional.IsDefined(CancelledAt)) + if (property.NameEquals("error_file_id"u8)) { - writer.WritePropertyName("cancelled_at"u8); - writer.WriteNumberValue(CancelledAt.Value, "U"); + errorFileId = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("request_counts") != true && Optional.IsDefined(RequestCounts)) + if (property.NameEquals("created_at"u8)) { - writer.WritePropertyName("request_counts"u8); - writer.WriteObjectValue(RequestCounts, options); + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + if (property.NameEquals("in_progress_at"u8)) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + if (property.Value.ValueKind == JsonValueKind.Null) { - writer.WriteNull("metadata"); + continue; } + inProgressAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - if (SerializedAdditionalRawData != null) + if (property.NameEquals("expires_at"u8)) { - foreach (var item in SerializedAdditionalRawData) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + continue; } + expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - writer.WriteEndObject(); - } - - InternalBatchJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (property.NameEquals("finalizing_at"u8)) { - throw new FormatException($"The model {nameof(InternalBatchJob)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchJob(document.RootElement, options); - } - - internal static InternalBatchJob DeserializeInternalBatchJob(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - InternalBatchObject @object = default; - string endpoint = default; - InternalBatchErrors errors = default; - string inputFileId = default; - string completionWindow = default; - InternalBatchStatus status = default; - string outputFileId = default; - string errorFileId = default; - DateTimeOffset createdAt = default; - DateTimeOffset? inProgressAt = default; - DateTimeOffset? expiresAt = default; - DateTimeOffset? finalizingAt = default; - DateTimeOffset? completedAt = default; - DateTimeOffset? failedAt = default; - DateTimeOffset? expiredAt = default; - DateTimeOffset? cancellingAt = default; - DateTimeOffset? cancelledAt = default; - InternalBatchRequestCounts requestCounts = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalBatchObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("endpoint"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - endpoint = property.Value.GetString(); continue; } - if (property.NameEquals("errors"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - errors = InternalBatchErrors.DeserializeInternalBatchErrors(property.Value, options); - continue; - } - if (property.NameEquals("input_file_id"u8)) - { - inputFileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("completion_window"u8)) - { - completionWindow = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new InternalBatchStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("output_file_id"u8)) - { - outputFileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("error_file_id"u8)) - { - errorFileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("in_progress_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - inProgressAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("expires_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("finalizing_at"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - finalizingAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("completed_at"u8)) + finalizingAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); continue; } - if (property.NameEquals("failed_at"u8)) + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("failed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); continue; } - if (property.NameEquals("expired_at"u8)) + failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("expired_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - expiredAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); continue; } - if (property.NameEquals("cancelling_at"u8)) + expiredAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("cancelling_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - cancellingAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); continue; } - if (property.NameEquals("cancelled_at"u8)) + cancellingAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("cancelled_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); continue; } - if (property.NameEquals("request_counts"u8)) + cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("request_counts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - requestCounts = InternalBatchRequestCounts.DeserializeInternalBatchRequestCounts(property.Value, options); continue; } - if (property.NameEquals("metadata"u8)) + requestCounts = InternalBatchRequestCounts.DeserializeInternalBatchRequestCounts(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchJob( - id, - @object, - endpoint, - errors, - inputFileId, - completionWindow, - status, - outputFileId, - errorFileId, - createdAt, - inProgressAt, - expiresAt, - finalizingAt, - completedAt, - failedAt, - expiredAt, - cancellingAt, - cancelledAt, - requestCounts, - metadata ?? new ChangeTrackingDictionary(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchJob)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchJob( + id, + @object, + endpoint, + errors, + inputFileId, + completionWindow, + status, + outputFileId, + errorFileId, + createdAt, + inProgressAt, + expiresAt, + finalizingAt, + completedAt, + failedAt, + expiredAt, + cancellingAt, + cancelledAt, + requestCounts, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } - InternalBatchJob IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchJob(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchJob)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchJob)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalBatchJob IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchJob FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchJob(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchJob(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchJob)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchJob FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchJob(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchJob.cs b/src/Generated/Models/InternalBatchJob.cs index bbd35aea..58eb466a 100644 --- a/src/Generated/Models/InternalBatchJob.cs +++ b/src/Generated/Models/InternalBatchJob.cs @@ -5,76 +5,75 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchJob { - internal partial class InternalBatchJob + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalBatchJob(string id, string endpoint, string inputFileId, string completionWindow, InternalBatchStatus status, DateTimeOffset createdAt) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalBatchJob(string id, string endpoint, string inputFileId, string completionWindow, InternalBatchStatus status, DateTimeOffset createdAt) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(inputFileId, nameof(inputFileId)); - Argument.AssertNotNull(completionWindow, nameof(completionWindow)); + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(inputFileId, nameof(inputFileId)); + Argument.AssertNotNull(completionWindow, nameof(completionWindow)); - Id = id; - Endpoint = endpoint; - InputFileId = inputFileId; - CompletionWindow = completionWindow; - Status = status; - CreatedAt = createdAt; - Metadata = new ChangeTrackingDictionary(); - } + Id = id; + Endpoint = endpoint; + InputFileId = inputFileId; + CompletionWindow = completionWindow; + Status = status; + CreatedAt = createdAt; + Metadata = new ChangeTrackingDictionary(); + } - internal InternalBatchJob(string id, InternalBatchObject @object, string endpoint, InternalBatchErrors errors, string inputFileId, string completionWindow, InternalBatchStatus status, string outputFileId, string errorFileId, DateTimeOffset createdAt, DateTimeOffset? inProgressAt, DateTimeOffset? expiresAt, DateTimeOffset? finalizingAt, DateTimeOffset? completedAt, DateTimeOffset? failedAt, DateTimeOffset? expiredAt, DateTimeOffset? cancellingAt, DateTimeOffset? cancelledAt, InternalBatchRequestCounts requestCounts, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - Endpoint = endpoint; - Errors = errors; - InputFileId = inputFileId; - CompletionWindow = completionWindow; - Status = status; - OutputFileId = outputFileId; - ErrorFileId = errorFileId; - CreatedAt = createdAt; - InProgressAt = inProgressAt; - ExpiresAt = expiresAt; - FinalizingAt = finalizingAt; - CompletedAt = completedAt; - FailedAt = failedAt; - ExpiredAt = expiredAt; - CancellingAt = cancellingAt; - CancelledAt = cancelledAt; - RequestCounts = requestCounts; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalBatchJob(string id, InternalBatchObject @object, string endpoint, InternalBatchErrors errors, string inputFileId, string completionWindow, InternalBatchStatus status, string outputFileId, string errorFileId, DateTimeOffset createdAt, DateTimeOffset? inProgressAt, DateTimeOffset? expiresAt, DateTimeOffset? finalizingAt, DateTimeOffset? completedAt, DateTimeOffset? failedAt, DateTimeOffset? expiredAt, DateTimeOffset? cancellingAt, DateTimeOffset? cancelledAt, InternalBatchRequestCounts requestCounts, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + Endpoint = endpoint; + Errors = errors; + InputFileId = inputFileId; + CompletionWindow = completionWindow; + Status = status; + OutputFileId = outputFileId; + ErrorFileId = errorFileId; + CreatedAt = createdAt; + InProgressAt = inProgressAt; + ExpiresAt = expiresAt; + FinalizingAt = finalizingAt; + CompletedAt = completedAt; + FailedAt = failedAt; + ExpiredAt = expiredAt; + CancellingAt = cancellingAt; + CancelledAt = cancelledAt; + RequestCounts = requestCounts; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal InternalBatchJob() - { - } + internal InternalBatchJob() + { + } - public string Id { get; } - public InternalBatchObject Object { get; } = InternalBatchObject.Batch; + public string Id { get; } + public InternalBatchObject Object { get; } = InternalBatchObject.Batch; - public string Endpoint { get; } - public InternalBatchErrors Errors { get; } - public string InputFileId { get; } - public string CompletionWindow { get; } - public InternalBatchStatus Status { get; } - public string OutputFileId { get; } - public string ErrorFileId { get; } - public DateTimeOffset CreatedAt { get; } - public DateTimeOffset? InProgressAt { get; } - public DateTimeOffset? ExpiresAt { get; } - public DateTimeOffset? FinalizingAt { get; } - public DateTimeOffset? CompletedAt { get; } - public DateTimeOffset? FailedAt { get; } - public DateTimeOffset? ExpiredAt { get; } - public DateTimeOffset? CancellingAt { get; } - public DateTimeOffset? CancelledAt { get; } - public InternalBatchRequestCounts RequestCounts { get; } - public IReadOnlyDictionary Metadata { get; } - } -} + public string Endpoint { get; } + public InternalBatchErrors Errors { get; } + public string InputFileId { get; } + public string CompletionWindow { get; } + public InternalBatchStatus Status { get; } + public string OutputFileId { get; } + public string ErrorFileId { get; } + public DateTimeOffset CreatedAt { get; } + public DateTimeOffset? InProgressAt { get; } + public DateTimeOffset? ExpiresAt { get; } + public DateTimeOffset? FinalizingAt { get; } + public DateTimeOffset? CompletedAt { get; } + public DateTimeOffset? FailedAt { get; } + public DateTimeOffset? ExpiredAt { get; } + public DateTimeOffset? CancellingAt { get; } + public DateTimeOffset? CancelledAt { get; } + public InternalBatchRequestCounts RequestCounts { get; } + public IReadOnlyDictionary Metadata { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchObject.cs b/src/Generated/Models/InternalBatchObject.cs index 96ff270e..e64177ed 100644 --- a/src/Generated/Models/InternalBatchObject.cs +++ b/src/Generated/Models/InternalBatchObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal readonly partial struct InternalBatchObject : IEquatable { - internal readonly partial struct InternalBatchObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalBatchObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalBatchObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string BatchValue = "batch"; + private const string BatchValue = "batch"; - public static InternalBatchObject Batch { get; } = new InternalBatchObject(BatchValue); - public static bool operator ==(InternalBatchObject left, InternalBatchObject right) => left.Equals(right); - public static bool operator !=(InternalBatchObject left, InternalBatchObject right) => !left.Equals(right); - public static implicit operator InternalBatchObject(string value) => new InternalBatchObject(value); + public static InternalBatchObject Batch { get; } = new InternalBatchObject(BatchValue); + public static bool operator ==(InternalBatchObject left, InternalBatchObject right) => left.Equals(right); + public static bool operator !=(InternalBatchObject left, InternalBatchObject right) => !left.Equals(right); + public static implicit operator InternalBatchObject(string value) => new InternalBatchObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalBatchObject other && Equals(other); - public bool Equals(InternalBatchObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalBatchObject other && Equals(other); + public bool Equals(InternalBatchObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestCounts.Serialization.cs b/src/Generated/Models/InternalBatchRequestCounts.Serialization.cs index ad7ad277..2f69e5c2 100644 --- a/src/Generated/Models/InternalBatchRequestCounts.Serialization.cs +++ b/src/Generated/Models/InternalBatchRequestCounts.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestCounts : IJsonModel { - internal partial class InternalBatchRequestCounts : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("total") != true) - { - writer.WritePropertyName("total"u8); - writer.WriteNumberValue(Total); - } - if (SerializedAdditionalRawData?.ContainsKey("completed") != true) - { - writer.WritePropertyName("completed"u8); - writer.WriteNumberValue(Completed); - } - if (SerializedAdditionalRawData?.ContainsKey("failed") != true) - { - writer.WritePropertyName("failed"u8); - writer.WriteNumberValue(Failed); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("total") != true) + { + writer.WritePropertyName("total"u8); + writer.WriteNumberValue(Total); + } + if (SerializedAdditionalRawData?.ContainsKey("completed") != true) + { + writer.WritePropertyName("completed"u8); + writer.WriteNumberValue(Completed); + } + if (SerializedAdditionalRawData?.ContainsKey("failed") != true) + { + writer.WritePropertyName("failed"u8); + writer.WriteNumberValue(Failed); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalBatchRequestCounts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalBatchRequestCounts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchRequestCounts(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support reading '{format}' format."); } - internal static InternalBatchRequestCounts DeserializeInternalBatchRequestCounts(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchRequestCounts(document.RootElement, options); + } + + internal static InternalBatchRequestCounts DeserializeInternalBatchRequestCounts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int total = default; + int completed = default; + int failed = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("total"u8)) { - return null; + total = property.Value.GetInt32(); + continue; } - int total = default; - int completed = default; - int failed = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("completed"u8)) { - if (property.NameEquals("total"u8)) - { - total = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("completed"u8)) - { - completed = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("failed"u8)) - { - failed = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + completed = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchRequestCounts(total, completed, failed, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("failed"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support writing '{options.Format}' format."); + failed = property.Value.GetInt32(); + continue; } - } - - InternalBatchRequestCounts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchRequestCounts(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchRequestCounts(total, completed, failed, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchRequestCounts FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchRequestCounts(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support writing '{options.Format}' format."); } + } + + InternalBatchRequestCounts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchRequestCounts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchRequestCounts)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchRequestCounts FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchRequestCounts(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestCounts.cs b/src/Generated/Models/InternalBatchRequestCounts.cs index 1e9731e0..cf2b3b82 100644 --- a/src/Generated/Models/InternalBatchRequestCounts.cs +++ b/src/Generated/Models/InternalBatchRequestCounts.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestCounts { - internal partial class InternalBatchRequestCounts + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalBatchRequestCounts(int total, int completed, int failed) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalBatchRequestCounts(int total, int completed, int failed) - { - Total = total; - Completed = completed; - Failed = failed; - } - - internal InternalBatchRequestCounts(int total, int completed, int failed, IDictionary serializedAdditionalRawData) - { - Total = total; - Completed = completed; - Failed = failed; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Total = total; + Completed = completed; + Failed = failed; + } - internal InternalBatchRequestCounts() - { - } + internal InternalBatchRequestCounts(int total, int completed, int failed, IDictionary serializedAdditionalRawData) + { + Total = total; + Completed = completed; + Failed = failed; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int Total { get; } - public int Completed { get; } - public int Failed { get; } + internal InternalBatchRequestCounts() + { } -} + + public int Total { get; } + public int Completed { get; } + public int Failed { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestInput.Serialization.cs b/src/Generated/Models/InternalBatchRequestInput.Serialization.cs index fe753aed..60a2416e 100644 --- a/src/Generated/Models/InternalBatchRequestInput.Serialization.cs +++ b/src/Generated/Models/InternalBatchRequestInput.Serialization.cs @@ -8,156 +8,155 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestInput : IJsonModel { - internal partial class InternalBatchRequestInput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("custom_id") != true && Optional.IsDefined(CustomId)) - { - writer.WritePropertyName("custom_id"u8); - writer.WriteStringValue(CustomId); - } - if (SerializedAdditionalRawData?.ContainsKey("method") != true && Optional.IsDefined(Method)) - { - writer.WritePropertyName("method"u8); - writer.WriteStringValue(Method.Value.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(Url)) - { - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url.AbsoluteUri); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("custom_id") != true && Optional.IsDefined(CustomId)) + { + writer.WritePropertyName("custom_id"u8); + writer.WriteStringValue(CustomId); + } + if (SerializedAdditionalRawData?.ContainsKey("method") != true && Optional.IsDefined(Method)) + { + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method.Value.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(Url)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalBatchRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalBatchRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchRequestInput(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support reading '{format}' format."); } - internal static InternalBatchRequestInput DeserializeInternalBatchRequestInput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchRequestInput(document.RootElement, options); + } + + internal static InternalBatchRequestInput DeserializeInternalBatchRequestInput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string customId = default; + InternalBatchRequestInputMethod? method = default; + Uri url = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("custom_id"u8)) { - return null; + customId = property.Value.GetString(); + continue; } - string customId = default; - InternalBatchRequestInputMethod? method = default; - Uri url = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("method"u8)) { - if (property.NameEquals("custom_id"u8)) - { - customId = property.Value.GetString(); - continue; - } - if (property.NameEquals("method"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - method = new InternalBatchRequestInputMethod(property.Value.GetString()); continue; } - if (property.NameEquals("url"u8)) + method = new InternalBatchRequestInputMethod(property.Value.GetString()); + continue; + } + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - url = new Uri(property.Value.GetString()); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + url = new Uri(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchRequestInput(customId, method, url, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchRequestInput(customId, method, url, serializedAdditionalRawData); + } - InternalBatchRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchRequestInput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalBatchRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchRequestInput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchRequestInput(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchRequestInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchRequestInput)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchRequestInput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchRequestInput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestInput.cs b/src/Generated/Models/InternalBatchRequestInput.cs index 7e4b58c9..9dd2021b 100644 --- a/src/Generated/Models/InternalBatchRequestInput.cs +++ b/src/Generated/Models/InternalBatchRequestInput.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestInput { - internal partial class InternalBatchRequestInput + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalBatchRequestInput() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalBatchRequestInput() - { - } - - internal InternalBatchRequestInput(string customId, InternalBatchRequestInputMethod? method, Uri url, IDictionary serializedAdditionalRawData) - { - CustomId = customId; - Method = method; - Url = url; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string CustomId { get; set; } - public InternalBatchRequestInputMethod? Method { get; set; } - public Uri Url { get; set; } + internal InternalBatchRequestInput(string customId, InternalBatchRequestInputMethod? method, Uri url, IDictionary serializedAdditionalRawData) + { + CustomId = customId; + Method = method; + Url = url; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string CustomId { get; set; } + public InternalBatchRequestInputMethod? Method { get; set; } + public Uri Url { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestInputMethod.cs b/src/Generated/Models/InternalBatchRequestInputMethod.cs index daff5451..ee2be62b 100644 --- a/src/Generated/Models/InternalBatchRequestInputMethod.cs +++ b/src/Generated/Models/InternalBatchRequestInputMethod.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal readonly partial struct InternalBatchRequestInputMethod : IEquatable { - internal readonly partial struct InternalBatchRequestInputMethod : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalBatchRequestInputMethod(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalBatchRequestInputMethod(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string POSTValue = "POST"; + private const string POSTValue = "POST"; - public static InternalBatchRequestInputMethod POST { get; } = new InternalBatchRequestInputMethod(POSTValue); - public static bool operator ==(InternalBatchRequestInputMethod left, InternalBatchRequestInputMethod right) => left.Equals(right); - public static bool operator !=(InternalBatchRequestInputMethod left, InternalBatchRequestInputMethod right) => !left.Equals(right); - public static implicit operator InternalBatchRequestInputMethod(string value) => new InternalBatchRequestInputMethod(value); + public static InternalBatchRequestInputMethod POST { get; } = new InternalBatchRequestInputMethod(POSTValue); + public static bool operator ==(InternalBatchRequestInputMethod left, InternalBatchRequestInputMethod right) => left.Equals(right); + public static bool operator !=(InternalBatchRequestInputMethod left, InternalBatchRequestInputMethod right) => !left.Equals(right); + public static implicit operator InternalBatchRequestInputMethod(string value) => new InternalBatchRequestInputMethod(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalBatchRequestInputMethod other && Equals(other); - public bool Equals(InternalBatchRequestInputMethod other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalBatchRequestInputMethod other && Equals(other); + public bool Equals(InternalBatchRequestInputMethod other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestOutput.Serialization.cs b/src/Generated/Models/InternalBatchRequestOutput.Serialization.cs index cd87dfd3..1de465a7 100644 --- a/src/Generated/Models/InternalBatchRequestOutput.Serialization.cs +++ b/src/Generated/Models/InternalBatchRequestOutput.Serialization.cs @@ -8,183 +8,182 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestOutput : IJsonModel { - internal partial class InternalBatchRequestOutput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("custom_id") != true && Optional.IsDefined(CustomId)) + { + writer.WritePropertyName("custom_id"u8); + writer.WriteStringValue(CustomId); + } + if (SerializedAdditionalRawData?.ContainsKey("response") != true && Optional.IsDefined(Response)) + { + if (Response != null) { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WritePropertyName("response"u8); + writer.WriteObjectValue(Response, options); } - if (SerializedAdditionalRawData?.ContainsKey("custom_id") != true && Optional.IsDefined(CustomId)) + else { - writer.WritePropertyName("custom_id"u8); - writer.WriteStringValue(CustomId); + writer.WriteNull("response"); } - if (SerializedAdditionalRawData?.ContainsKey("response") != true && Optional.IsDefined(Response)) + } + if (SerializedAdditionalRawData?.ContainsKey("error") != true && Optional.IsDefined(Error)) + { + if (Error != null) { - if (Response != null) - { - writer.WritePropertyName("response"u8); - writer.WriteObjectValue(Response, options); - } - else - { - writer.WriteNull("response"); - } + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); } - if (SerializedAdditionalRawData?.ContainsKey("error") != true && Optional.IsDefined(Error)) + else { - if (Error != null) - { - writer.WritePropertyName("error"u8); - writer.WriteObjectValue(Error, options); - } - else - { - writer.WriteNull("error"); - } + writer.WriteNull("error"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalBatchRequestOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalBatchRequestOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchRequestOutput(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support reading '{format}' format."); } - internal static InternalBatchRequestOutput DeserializeInternalBatchRequestOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchRequestOutput(document.RootElement, options); + } + + internal static InternalBatchRequestOutput DeserializeInternalBatchRequestOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string customId = default; + InternalBatchRequestOutputResponse response = default; + InternalBatchRequestOutputError error = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - string customId = default; - InternalBatchRequestOutputResponse response = default; - InternalBatchRequestOutputError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("custom_id"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("custom_id"u8)) - { - customId = property.Value.GetString(); - continue; - } - if (property.NameEquals("response"u8)) + customId = property.Value.GetString(); + continue; + } + if (property.NameEquals("response"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - response = null; - continue; - } - response = InternalBatchRequestOutputResponse.DeserializeInternalBatchRequestOutputResponse(property.Value, options); + response = null; continue; } - if (property.NameEquals("error"u8)) + response = InternalBatchRequestOutputResponse.DeserializeInternalBatchRequestOutputResponse(property.Value, options); + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - error = null; - continue; - } - error = InternalBatchRequestOutputError.DeserializeInternalBatchRequestOutputError(property.Value, options); + error = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + error = InternalBatchRequestOutputError.DeserializeInternalBatchRequestOutputError(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchRequestOutput(id, customId, response, error, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchRequestOutput(id, customId, response, error, serializedAdditionalRawData); + } - InternalBatchRequestOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchRequestOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalBatchRequestOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchRequestOutput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchRequestOutput(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchRequestOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchRequestOutput)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchRequestOutput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchRequestOutput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestOutput.cs b/src/Generated/Models/InternalBatchRequestOutput.cs index ae119ecd..52937750 100644 --- a/src/Generated/Models/InternalBatchRequestOutput.cs +++ b/src/Generated/Models/InternalBatchRequestOutput.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestOutput { - internal partial class InternalBatchRequestOutput + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalBatchRequestOutput() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalBatchRequestOutput() - { - } - - internal InternalBatchRequestOutput(string id, string customId, InternalBatchRequestOutputResponse response, InternalBatchRequestOutputError error, IDictionary serializedAdditionalRawData) - { - Id = id; - CustomId = customId; - Response = response; - Error = error; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string Id { get; } - public string CustomId { get; } - public InternalBatchRequestOutputResponse Response { get; } - public InternalBatchRequestOutputError Error { get; } + internal InternalBatchRequestOutput(string id, string customId, InternalBatchRequestOutputResponse response, InternalBatchRequestOutputError error, IDictionary serializedAdditionalRawData) + { + Id = id; + CustomId = customId; + Response = response; + Error = error; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Id { get; } + public string CustomId { get; } + public InternalBatchRequestOutputResponse Response { get; } + public InternalBatchRequestOutputError Error { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestOutputError.Serialization.cs b/src/Generated/Models/InternalBatchRequestOutputError.Serialization.cs index 00f747f1..3a4e1e04 100644 --- a/src/Generated/Models/InternalBatchRequestOutputError.Serialization.cs +++ b/src/Generated/Models/InternalBatchRequestOutputError.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestOutputError : IJsonModel { - internal partial class InternalBatchRequestOutputError : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) - { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code); - } - if (SerializedAdditionalRawData?.ContainsKey("message") != true && Optional.IsDefined(Message)) - { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalBatchRequestOutputError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalBatchRequestOutputError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchRequestOutputError(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support reading '{format}' format."); } - internal static InternalBatchRequestOutputError DeserializeInternalBatchRequestOutputError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchRequestOutputError(document.RootElement, options); + } + + internal static InternalBatchRequestOutputError DeserializeInternalBatchRequestOutputError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) { - return null; + code = property.Value.GetString(); + continue; } - string code = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("message"u8)) { - if (property.NameEquals("code"u8)) - { - code = property.Value.GetString(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + message = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchRequestOutputError(code, message, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchRequestOutputError(code, message, serializedAdditionalRawData); + } - InternalBatchRequestOutputError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchRequestOutputError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalBatchRequestOutputError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchRequestOutputError FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchRequestOutputError(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchRequestOutputError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchRequestOutputError)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchRequestOutputError FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchRequestOutputError(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestOutputError.cs b/src/Generated/Models/InternalBatchRequestOutputError.cs index b2ddd5be..8f2478fe 100644 --- a/src/Generated/Models/InternalBatchRequestOutputError.cs +++ b/src/Generated/Models/InternalBatchRequestOutputError.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestOutputError { - internal partial class InternalBatchRequestOutputError + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalBatchRequestOutputError() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalBatchRequestOutputError() - { - } - - internal InternalBatchRequestOutputError(string code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string Code { get; } - public string Message { get; } + internal InternalBatchRequestOutputError(string code, string message, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Code { get; } + public string Message { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestOutputResponse.Serialization.cs b/src/Generated/Models/InternalBatchRequestOutputResponse.Serialization.cs index 5f48d809..06846967 100644 --- a/src/Generated/Models/InternalBatchRequestOutputResponse.Serialization.cs +++ b/src/Generated/Models/InternalBatchRequestOutputResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestOutputResponse : IJsonModel { - internal partial class InternalBatchRequestOutputResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support writing '{format}' format."); + } + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("status_code") != true && Optional.IsDefined(StatusCode)) + { + writer.WritePropertyName("status_code"u8); + writer.WriteNumberValue(StatusCode.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("request_id") != true && Optional.IsDefined(RequestId)) + { + writer.WritePropertyName("request_id"u8); + writer.WriteStringValue(RequestId); + } + if (SerializedAdditionalRawData?.ContainsKey("body") != true && Optional.IsCollectionDefined(Body)) + { + writer.WritePropertyName("body"u8); writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("status_code") != true && Optional.IsDefined(StatusCode)) - { - writer.WritePropertyName("status_code"u8); - writer.WriteNumberValue(StatusCode.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("request_id") != true && Optional.IsDefined(RequestId)) + foreach (var item in Body) { - writer.WritePropertyName("request_id"u8); - writer.WriteStringValue(RequestId); - } - if (SerializedAdditionalRawData?.ContainsKey("body") != true && Optional.IsCollectionDefined(Body)) - { - writer.WritePropertyName("body"u8); - writer.WriteStartObject(); - foreach (var item in Body) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } + writer.WriteNullValue(); + continue; + } #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - writer.WriteEndObject(); +#endif } - if (SerializedAdditionalRawData != null) + writer.WriteEndObject(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalBatchRequestOutputResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalBatchRequestOutputResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBatchRequestOutputResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support reading '{format}' format."); } - internal static InternalBatchRequestOutputResponse DeserializeInternalBatchRequestOutputResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalBatchRequestOutputResponse(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int? statusCode = default; - string requestId = default; - IReadOnlyDictionary body = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalBatchRequestOutputResponse DeserializeInternalBatchRequestOutputResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? statusCode = default; + string requestId = default; + IReadOnlyDictionary body = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("status_code"u8)) { - if (property.NameEquals("status_code"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - statusCode = property.Value.GetInt32(); continue; } - if (property.NameEquals("request_id"u8)) + statusCode = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("request_id"u8)) + { + requestId = property.Value.GetString(); + continue; + } + if (property.NameEquals("body"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - requestId = property.Value.GetString(); continue; } - if (property.NameEquals("body"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (property0.Value.ValueKind == JsonValueKind.Null) { - continue; + dictionary.Add(property0.Name, null); } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + else { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - dictionary.Add(property0.Name, null); - } - else - { - dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); - } + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); } - body = dictionary; - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } + body = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBatchRequestOutputResponse(statusCode, requestId, body ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalBatchRequestOutputResponse(statusCode, requestId, body ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - InternalBatchRequestOutputResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBatchRequestOutputResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalBatchRequestOutputResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalBatchRequestOutputResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBatchRequestOutputResponse(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalBatchRequestOutputResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalBatchRequestOutputResponse)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalBatchRequestOutputResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalBatchRequestOutputResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchRequestOutputResponse.cs b/src/Generated/Models/InternalBatchRequestOutputResponse.cs index 8435f20d..bcc0643e 100644 --- a/src/Generated/Models/InternalBatchRequestOutputResponse.cs +++ b/src/Generated/Models/InternalBatchRequestOutputResponse.cs @@ -5,26 +5,25 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalBatchRequestOutputResponse { - internal partial class InternalBatchRequestOutputResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalBatchRequestOutputResponse() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalBatchRequestOutputResponse() - { - Body = new ChangeTrackingDictionary(); - } - - internal InternalBatchRequestOutputResponse(int? statusCode, string requestId, IReadOnlyDictionary body, IDictionary serializedAdditionalRawData) - { - StatusCode = statusCode; - RequestId = requestId; - Body = body; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Body = new ChangeTrackingDictionary(); + } - public int? StatusCode { get; } - public string RequestId { get; } - public IReadOnlyDictionary Body { get; } + internal InternalBatchRequestOutputResponse(int? statusCode, string requestId, IReadOnlyDictionary body, IDictionary serializedAdditionalRawData) + { + StatusCode = statusCode; + RequestId = requestId; + Body = body; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public int? StatusCode { get; } + public string RequestId { get; } + public IReadOnlyDictionary Body { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalBatchStatus.cs b/src/Generated/Models/InternalBatchStatus.cs index b34fe0bf..ef428d0f 100644 --- a/src/Generated/Models/InternalBatchStatus.cs +++ b/src/Generated/Models/InternalBatchStatus.cs @@ -5,44 +5,43 @@ using System; using System.ComponentModel; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal readonly partial struct InternalBatchStatus : IEquatable { - internal readonly partial struct InternalBatchStatus : IEquatable + private readonly string _value; + + public InternalBatchStatus(string value) { - private readonly string _value; - - public InternalBatchStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ValidatingValue = "validating"; - private const string FailedValue = "failed"; - private const string InProgressValue = "in_progress"; - private const string FinalizingValue = "finalizing"; - private const string CompletedValue = "completed"; - private const string ExpiredValue = "expired"; - private const string CancellingValue = "cancelling"; - private const string CancelledValue = "cancelled"; - - public static InternalBatchStatus Validating { get; } = new InternalBatchStatus(ValidatingValue); - public static InternalBatchStatus Failed { get; } = new InternalBatchStatus(FailedValue); - public static InternalBatchStatus InProgress { get; } = new InternalBatchStatus(InProgressValue); - public static InternalBatchStatus Finalizing { get; } = new InternalBatchStatus(FinalizingValue); - public static InternalBatchStatus Completed { get; } = new InternalBatchStatus(CompletedValue); - public static InternalBatchStatus Expired { get; } = new InternalBatchStatus(ExpiredValue); - public static InternalBatchStatus Cancelling { get; } = new InternalBatchStatus(CancellingValue); - public static InternalBatchStatus Cancelled { get; } = new InternalBatchStatus(CancelledValue); - public static bool operator ==(InternalBatchStatus left, InternalBatchStatus right) => left.Equals(right); - public static bool operator !=(InternalBatchStatus left, InternalBatchStatus right) => !left.Equals(right); - public static implicit operator InternalBatchStatus(string value) => new InternalBatchStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalBatchStatus other && Equals(other); - public bool Equals(InternalBatchStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string ValidatingValue = "validating"; + private const string FailedValue = "failed"; + private const string InProgressValue = "in_progress"; + private const string FinalizingValue = "finalizing"; + private const string CompletedValue = "completed"; + private const string ExpiredValue = "expired"; + private const string CancellingValue = "cancelling"; + private const string CancelledValue = "cancelled"; + + public static InternalBatchStatus Validating { get; } = new InternalBatchStatus(ValidatingValue); + public static InternalBatchStatus Failed { get; } = new InternalBatchStatus(FailedValue); + public static InternalBatchStatus InProgress { get; } = new InternalBatchStatus(InProgressValue); + public static InternalBatchStatus Finalizing { get; } = new InternalBatchStatus(FinalizingValue); + public static InternalBatchStatus Completed { get; } = new InternalBatchStatus(CompletedValue); + public static InternalBatchStatus Expired { get; } = new InternalBatchStatus(ExpiredValue); + public static InternalBatchStatus Cancelling { get; } = new InternalBatchStatus(CancellingValue); + public static InternalBatchStatus Cancelled { get; } = new InternalBatchStatus(CancelledValue); + public static bool operator ==(InternalBatchStatus left, InternalBatchStatus right) => left.Equals(right); + public static bool operator !=(InternalBatchStatus left, InternalBatchStatus right) => !left.Equals(right); + public static implicit operator InternalBatchStatus(string value) => new InternalBatchStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalBatchStatus other && Equals(other); + public bool Equals(InternalBatchStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionFunctionCallOption.Serialization.cs b/src/Generated/Models/InternalChatCompletionFunctionCallOption.Serialization.cs index b8f41948..ca75b2b9 100644 --- a/src/Generated/Models/InternalChatCompletionFunctionCallOption.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionFunctionCallOption.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionFunctionCallOption : IJsonModel { - internal partial class InternalChatCompletionFunctionCallOption : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support writing '{format}' format."); } - InternalChatCompletionFunctionCallOption IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionFunctionCallOption(document.RootElement, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - internal static InternalChatCompletionFunctionCallOption DeserializeInternalChatCompletionFunctionCallOption(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("name"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - name = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionFunctionCallOption(name, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalChatCompletionFunctionCallOption IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support reading '{format}' format."); } - InternalChatCompletionFunctionCallOption IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionFunctionCallOption(document.RootElement, options); + } + + internal static InternalChatCompletionFunctionCallOption DeserializeInternalChatCompletionFunctionCallOption(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionFunctionCallOption(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support reading '{options.Format}' format."); + name = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionFunctionCallOption(name, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionFunctionCallOption FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionFunctionCallOption(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support writing '{options.Format}' format."); } + } + + InternalChatCompletionFunctionCallOption IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionFunctionCallOption(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionFunctionCallOption)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionFunctionCallOption FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionFunctionCallOption(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionFunctionCallOption.cs b/src/Generated/Models/InternalChatCompletionFunctionCallOption.cs index 2cb95446..5109b625 100644 --- a/src/Generated/Models/InternalChatCompletionFunctionCallOption.cs +++ b/src/Generated/Models/InternalChatCompletionFunctionCallOption.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionFunctionCallOption { - internal partial class InternalChatCompletionFunctionCallOption + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionFunctionCallOption(string name) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionFunctionCallOption(string name) - { - Argument.AssertNotNull(name, nameof(name)); - - Name = name; - } + Argument.AssertNotNull(name, nameof(name)); - internal InternalChatCompletionFunctionCallOption(string name, IDictionary serializedAdditionalRawData) - { - Name = name; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Name = name; + } - internal InternalChatCompletionFunctionCallOption() - { - } + internal InternalChatCompletionFunctionCallOption(string name, IDictionary serializedAdditionalRawData) + { + Name = name; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string Name { get; } + internal InternalChatCompletionFunctionCallOption() + { } -} + + public string Name { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.Serialization.cs b/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.Serialization.cs index 40c34b17..b24c5535 100644 --- a/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionMessageToolCallChunkFunction : IJsonModel { - internal partial class InternalChatCompletionMessageToolCallChunkFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true && Optional.IsDefined(Arguments)) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true && Optional.IsDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionMessageToolCallChunkFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionMessageToolCallChunkFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionMessageToolCallChunkFunction(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support reading '{format}' format."); } - internal static InternalChatCompletionMessageToolCallChunkFunction DeserializeInternalChatCompletionMessageToolCallChunkFunction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionMessageToolCallChunkFunction(document.RootElement, options); + } + + internal static InternalChatCompletionMessageToolCallChunkFunction DeserializeInternalChatCompletionMessageToolCallChunkFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - string arguments = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("arguments"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + arguments = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionMessageToolCallChunkFunction(name, arguments, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionMessageToolCallChunkFunction(name, arguments, serializedAdditionalRawData); + } - InternalChatCompletionMessageToolCallChunkFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionMessageToolCallChunkFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionMessageToolCallChunkFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionMessageToolCallChunkFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionMessageToolCallChunkFunction(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionMessageToolCallChunkFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallChunkFunction)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionMessageToolCallChunkFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionMessageToolCallChunkFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.cs b/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.cs index 3119ca2e..8bb6c0de 100644 --- a/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.cs +++ b/src/Generated/Models/InternalChatCompletionMessageToolCallChunkFunction.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionMessageToolCallChunkFunction { - internal partial class InternalChatCompletionMessageToolCallChunkFunction + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalChatCompletionMessageToolCallChunkFunction() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalChatCompletionMessageToolCallChunkFunction() - { - } - - internal InternalChatCompletionMessageToolCallChunkFunction(string name, string arguments, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string Name { get; } - public string Arguments { get; } + internal InternalChatCompletionMessageToolCallChunkFunction(string name, string arguments, IDictionary serializedAdditionalRawData) + { + Name = name; + Arguments = arguments; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Name { get; } + public string Arguments { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionMessageToolCallChunkType.cs b/src/Generated/Models/InternalChatCompletionMessageToolCallChunkType.cs index ea62bf0a..4e4b297f 100644 --- a/src/Generated/Models/InternalChatCompletionMessageToolCallChunkType.cs +++ b/src/Generated/Models/InternalChatCompletionMessageToolCallChunkType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalChatCompletionMessageToolCallChunkType : IEquatable { - internal readonly partial struct InternalChatCompletionMessageToolCallChunkType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalChatCompletionMessageToolCallChunkType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalChatCompletionMessageToolCallChunkType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FunctionValue = "function"; + private const string FunctionValue = "function"; - public static InternalChatCompletionMessageToolCallChunkType Function { get; } = new InternalChatCompletionMessageToolCallChunkType(FunctionValue); - public static bool operator ==(InternalChatCompletionMessageToolCallChunkType left, InternalChatCompletionMessageToolCallChunkType right) => left.Equals(right); - public static bool operator !=(InternalChatCompletionMessageToolCallChunkType left, InternalChatCompletionMessageToolCallChunkType right) => !left.Equals(right); - public static implicit operator InternalChatCompletionMessageToolCallChunkType(string value) => new InternalChatCompletionMessageToolCallChunkType(value); + public static InternalChatCompletionMessageToolCallChunkType Function { get; } = new InternalChatCompletionMessageToolCallChunkType(FunctionValue); + public static bool operator ==(InternalChatCompletionMessageToolCallChunkType left, InternalChatCompletionMessageToolCallChunkType right) => left.Equals(right); + public static bool operator !=(InternalChatCompletionMessageToolCallChunkType left, InternalChatCompletionMessageToolCallChunkType right) => !left.Equals(right); + public static implicit operator InternalChatCompletionMessageToolCallChunkType(string value) => new InternalChatCompletionMessageToolCallChunkType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalChatCompletionMessageToolCallChunkType other && Equals(other); - public bool Equals(InternalChatCompletionMessageToolCallChunkType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionMessageToolCallChunkType other && Equals(other); + public bool Equals(InternalChatCompletionMessageToolCallChunkType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.Serialization.cs b/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.Serialization.cs index bb71f2b4..24b352de 100644 --- a/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionMessageToolCallFunction : IJsonModel { - internal partial class InternalChatCompletionMessageToolCallFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionMessageToolCallFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionMessageToolCallFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionMessageToolCallFunction(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support reading '{format}' format."); } - internal static InternalChatCompletionMessageToolCallFunction DeserializeInternalChatCompletionMessageToolCallFunction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionMessageToolCallFunction(document.RootElement, options); + } + + internal static InternalChatCompletionMessageToolCallFunction DeserializeInternalChatCompletionMessageToolCallFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - string arguments = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("arguments"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + arguments = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionMessageToolCallFunction(name, arguments, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionMessageToolCallFunction(name, arguments, serializedAdditionalRawData); + } - InternalChatCompletionMessageToolCallFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionMessageToolCallFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionMessageToolCallFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionMessageToolCallFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionMessageToolCallFunction(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionMessageToolCallFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionMessageToolCallFunction)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionMessageToolCallFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionMessageToolCallFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.cs b/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.cs index c725868a..a583384d 100644 --- a/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.cs +++ b/src/Generated/Models/InternalChatCompletionMessageToolCallFunction.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionMessageToolCallFunction { - internal partial class InternalChatCompletionMessageToolCallFunction + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionMessageToolCallFunction(string name, string arguments) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + Name = name; + Arguments = arguments; + } + + internal InternalChatCompletionMessageToolCallFunction(string name, string arguments, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionMessageToolCallFunction(string name, string arguments) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(arguments, nameof(arguments)); - - Name = name; - Arguments = arguments; - } - - internal InternalChatCompletionMessageToolCallFunction(string name, string arguments, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalChatCompletionMessageToolCallFunction() - { - } - - public string Name { get; set; } - public string Arguments { get; set; } + Name = name; + Arguments = arguments; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalChatCompletionMessageToolCallFunction() + { + } + + public string Name { get; set; } + public string Arguments { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionNamedToolChoice.Serialization.cs b/src/Generated/Models/InternalChatCompletionNamedToolChoice.Serialization.cs index 447e3509..4605cce6 100644 --- a/src/Generated/Models/InternalChatCompletionNamedToolChoice.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionNamedToolChoice.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionNamedToolChoice : IJsonModel { - internal partial class InternalChatCompletionNamedToolChoice : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("function") != true) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("function") != true) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionNamedToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionNamedToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionNamedToolChoice(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support reading '{format}' format."); } - internal static InternalChatCompletionNamedToolChoice DeserializeInternalChatCompletionNamedToolChoice(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionNamedToolChoice(document.RootElement, options); + } + + internal static InternalChatCompletionNamedToolChoice DeserializeInternalChatCompletionNamedToolChoice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalChatCompletionNamedToolChoiceType type = default; + InternalChatCompletionNamedToolChoiceFunction function = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = new InternalChatCompletionNamedToolChoiceType(property.Value.GetString()); + continue; } - InternalChatCompletionNamedToolChoiceType type = default; - InternalChatCompletionNamedToolChoiceFunction function = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("function"u8)) { - if (property.NameEquals("type"u8)) - { - type = new InternalChatCompletionNamedToolChoiceType(property.Value.GetString()); - continue; - } - if (property.NameEquals("function"u8)) - { - function = InternalChatCompletionNamedToolChoiceFunction.DeserializeInternalChatCompletionNamedToolChoiceFunction(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + function = InternalChatCompletionNamedToolChoiceFunction.DeserializeInternalChatCompletionNamedToolChoiceFunction(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionNamedToolChoice(type, function, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionNamedToolChoice(type, function, serializedAdditionalRawData); + } - InternalChatCompletionNamedToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionNamedToolChoice(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionNamedToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionNamedToolChoice FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionNamedToolChoice(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionNamedToolChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoice)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionNamedToolChoice FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionNamedToolChoice(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionNamedToolChoice.cs b/src/Generated/Models/InternalChatCompletionNamedToolChoice.cs index 4538d813..a4d7e5fc 100644 --- a/src/Generated/Models/InternalChatCompletionNamedToolChoice.cs +++ b/src/Generated/Models/InternalChatCompletionNamedToolChoice.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionNamedToolChoice { - internal partial class InternalChatCompletionNamedToolChoice + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionNamedToolChoice(InternalChatCompletionNamedToolChoiceFunction function) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionNamedToolChoice(InternalChatCompletionNamedToolChoiceFunction function) - { - Argument.AssertNotNull(function, nameof(function)); + Argument.AssertNotNull(function, nameof(function)); - Function = function; - } + Function = function; + } - internal InternalChatCompletionNamedToolChoice(InternalChatCompletionNamedToolChoiceType type, InternalChatCompletionNamedToolChoiceFunction function, IDictionary serializedAdditionalRawData) - { - Type = type; - Function = function; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalChatCompletionNamedToolChoice(InternalChatCompletionNamedToolChoiceType type, InternalChatCompletionNamedToolChoiceFunction function, IDictionary serializedAdditionalRawData) + { + Type = type; + Function = function; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal InternalChatCompletionNamedToolChoice() - { - } + internal InternalChatCompletionNamedToolChoice() + { + } - public InternalChatCompletionNamedToolChoiceType Type { get; } = InternalChatCompletionNamedToolChoiceType.Function; + public InternalChatCompletionNamedToolChoiceType Type { get; } = InternalChatCompletionNamedToolChoiceType.Function; - public InternalChatCompletionNamedToolChoiceFunction Function { get; } - } -} + public InternalChatCompletionNamedToolChoiceFunction Function { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.Serialization.cs b/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.Serialization.cs index 8e0e339e..b62b8234 100644 --- a/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionNamedToolChoiceFunction : IJsonModel { - internal partial class InternalChatCompletionNamedToolChoiceFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support writing '{format}' format."); } - InternalChatCompletionNamedToolChoiceFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionNamedToolChoiceFunction(document.RootElement, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - internal static InternalChatCompletionNamedToolChoiceFunction DeserializeInternalChatCompletionNamedToolChoiceFunction(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("name"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - name = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionNamedToolChoiceFunction(name, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalChatCompletionNamedToolChoiceFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support reading '{format}' format."); } - InternalChatCompletionNamedToolChoiceFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionNamedToolChoiceFunction(document.RootElement, options); + } + + internal static InternalChatCompletionNamedToolChoiceFunction DeserializeInternalChatCompletionNamedToolChoiceFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionNamedToolChoiceFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support reading '{options.Format}' format."); + name = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionNamedToolChoiceFunction(name, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionNamedToolChoiceFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionNamedToolChoiceFunction(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support writing '{options.Format}' format."); } + } + + InternalChatCompletionNamedToolChoiceFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionNamedToolChoiceFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionNamedToolChoiceFunction)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionNamedToolChoiceFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionNamedToolChoiceFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.cs b/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.cs index 5097bcb7..b258af63 100644 --- a/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.cs +++ b/src/Generated/Models/InternalChatCompletionNamedToolChoiceFunction.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionNamedToolChoiceFunction { - internal partial class InternalChatCompletionNamedToolChoiceFunction + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionNamedToolChoiceFunction(string name) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionNamedToolChoiceFunction(string name) - { - Argument.AssertNotNull(name, nameof(name)); - - Name = name; - } + Argument.AssertNotNull(name, nameof(name)); - internal InternalChatCompletionNamedToolChoiceFunction(string name, IDictionary serializedAdditionalRawData) - { - Name = name; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Name = name; + } - internal InternalChatCompletionNamedToolChoiceFunction() - { - } + internal InternalChatCompletionNamedToolChoiceFunction(string name, IDictionary serializedAdditionalRawData) + { + Name = name; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string Name { get; } + internal InternalChatCompletionNamedToolChoiceFunction() + { } -} + + public string Name { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionNamedToolChoiceType.cs b/src/Generated/Models/InternalChatCompletionNamedToolChoiceType.cs index b5eda303..d2da307a 100644 --- a/src/Generated/Models/InternalChatCompletionNamedToolChoiceType.cs +++ b/src/Generated/Models/InternalChatCompletionNamedToolChoiceType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalChatCompletionNamedToolChoiceType : IEquatable { - internal readonly partial struct InternalChatCompletionNamedToolChoiceType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalChatCompletionNamedToolChoiceType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalChatCompletionNamedToolChoiceType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FunctionValue = "function"; + private const string FunctionValue = "function"; - public static InternalChatCompletionNamedToolChoiceType Function { get; } = new InternalChatCompletionNamedToolChoiceType(FunctionValue); - public static bool operator ==(InternalChatCompletionNamedToolChoiceType left, InternalChatCompletionNamedToolChoiceType right) => left.Equals(right); - public static bool operator !=(InternalChatCompletionNamedToolChoiceType left, InternalChatCompletionNamedToolChoiceType right) => !left.Equals(right); - public static implicit operator InternalChatCompletionNamedToolChoiceType(string value) => new InternalChatCompletionNamedToolChoiceType(value); + public static InternalChatCompletionNamedToolChoiceType Function { get; } = new InternalChatCompletionNamedToolChoiceType(FunctionValue); + public static bool operator ==(InternalChatCompletionNamedToolChoiceType left, InternalChatCompletionNamedToolChoiceType right) => left.Equals(right); + public static bool operator !=(InternalChatCompletionNamedToolChoiceType left, InternalChatCompletionNamedToolChoiceType right) => !left.Equals(right); + public static implicit operator InternalChatCompletionNamedToolChoiceType(string value) => new InternalChatCompletionNamedToolChoiceType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalChatCompletionNamedToolChoiceType other && Equals(other); - public bool Equals(InternalChatCompletionNamedToolChoiceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionNamedToolChoiceType other && Equals(other); + public bool Equals(InternalChatCompletionNamedToolChoiceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.Serialization.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.Serialization.cs index f348a091..3c193255 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartImage : IJsonModel { - internal partial class InternalChatCompletionRequestMessageContentPartImage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("image_url") != true) - { - writer.WritePropertyName("image_url"u8); - writer.WriteObjectValue(ImageUrl, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("image_url") != true) + { + writer.WritePropertyName("image_url"u8); + writer.WriteObjectValue(ImageUrl, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionRequestMessageContentPartImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionRequestMessageContentPartImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionRequestMessageContentPartImage(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support reading '{format}' format."); } - internal static InternalChatCompletionRequestMessageContentPartImage DeserializeInternalChatCompletionRequestMessageContentPartImage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionRequestMessageContentPartImage(document.RootElement, options); + } + + internal static InternalChatCompletionRequestMessageContentPartImage DeserializeInternalChatCompletionRequestMessageContentPartImage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalChatCompletionRequestMessageContentPartImageType type = default; + InternalChatCompletionRequestMessageContentPartImageImageUrl imageUrl = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = new InternalChatCompletionRequestMessageContentPartImageType(property.Value.GetString()); + continue; } - InternalChatCompletionRequestMessageContentPartImageType type = default; - InternalChatCompletionRequestMessageContentPartImageImageUrl imageUrl = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("image_url"u8)) { - if (property.NameEquals("type"u8)) - { - type = new InternalChatCompletionRequestMessageContentPartImageType(property.Value.GetString()); - continue; - } - if (property.NameEquals("image_url"u8)) - { - imageUrl = InternalChatCompletionRequestMessageContentPartImageImageUrl.DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + imageUrl = InternalChatCompletionRequestMessageContentPartImageImageUrl.DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionRequestMessageContentPartImage(type, imageUrl, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionRequestMessageContentPartImage(type, imageUrl, serializedAdditionalRawData); + } - InternalChatCompletionRequestMessageContentPartImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionRequestMessageContentPartImage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionRequestMessageContentPartImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionRequestMessageContentPartImage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionRequestMessageContentPartImage(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionRequestMessageContentPartImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImage)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionRequestMessageContentPartImage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionRequestMessageContentPartImage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.cs index 97fb5504..9b235eba 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImage.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartImage { - internal partial class InternalChatCompletionRequestMessageContentPartImage + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionRequestMessageContentPartImage(InternalChatCompletionRequestMessageContentPartImageImageUrl imageUrl) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionRequestMessageContentPartImage(InternalChatCompletionRequestMessageContentPartImageImageUrl imageUrl) - { - Argument.AssertNotNull(imageUrl, nameof(imageUrl)); + Argument.AssertNotNull(imageUrl, nameof(imageUrl)); - ImageUrl = imageUrl; - } + ImageUrl = imageUrl; + } - internal InternalChatCompletionRequestMessageContentPartImage(InternalChatCompletionRequestMessageContentPartImageType type, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUrl, IDictionary serializedAdditionalRawData) - { - Type = type; - ImageUrl = imageUrl; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalChatCompletionRequestMessageContentPartImage(InternalChatCompletionRequestMessageContentPartImageType type, InternalChatCompletionRequestMessageContentPartImageImageUrl imageUrl, IDictionary serializedAdditionalRawData) + { + Type = type; + ImageUrl = imageUrl; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal InternalChatCompletionRequestMessageContentPartImage() - { - } + internal InternalChatCompletionRequestMessageContentPartImage() + { + } - public InternalChatCompletionRequestMessageContentPartImageType Type { get; } = InternalChatCompletionRequestMessageContentPartImageType.ImageUrl; + public InternalChatCompletionRequestMessageContentPartImageType Type { get; } = InternalChatCompletionRequestMessageContentPartImageType.ImageUrl; - public InternalChatCompletionRequestMessageContentPartImageImageUrl ImageUrl { get; } - } -} + public InternalChatCompletionRequestMessageContentPartImageImageUrl ImageUrl { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.Serialization.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.Serialization.cs index e84cdd27..084a2306 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.Serialization.cs @@ -8,141 +8,140 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartImageImageUrl : IJsonModel { - internal partial class InternalChatCompletionRequestMessageContentPartImageImageUrl : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("url") != true) - { - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url); - } - if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) - { - writer.WritePropertyName("detail"u8); - writer.WriteStringValue(Detail.Value.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("url") != true) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + } + if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail.Value.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionRequestMessageContentPartImageImageUrl IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionRequestMessageContentPartImageImageUrl IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support reading '{format}' format."); } - internal static InternalChatCompletionRequestMessageContentPartImageImageUrl DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalChatCompletionRequestMessageContentPartImageImageUrl DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string url = default; + ChatImageDetailLevel? detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) { - return null; + url = property.Value.GetString(); + continue; } - string url = default; - ChatImageDetailLevel? detail = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("detail"u8)) { - if (property.NameEquals("url"u8)) - { - url = property.Value.GetString(); - continue; - } - if (property.NameEquals("detail"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - detail = new ChatImageDetailLevel(property.Value.GetString()); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + detail = new ChatImageDetailLevel(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionRequestMessageContentPartImageImageUrl(url, detail, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionRequestMessageContentPartImageImageUrl(url, detail, serializedAdditionalRawData); + } - InternalChatCompletionRequestMessageContentPartImageImageUrl IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionRequestMessageContentPartImageImageUrl IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionRequestMessageContentPartImageImageUrl FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartImageImageUrl)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionRequestMessageContentPartImageImageUrl FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionRequestMessageContentPartImageImageUrl(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs index e0e87271..ed1f66d6 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageImageUrl.cs @@ -5,15 +5,14 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartImageImageUrl { - internal partial class InternalChatCompletionRequestMessageContentPartImageImageUrl - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalChatCompletionRequestMessageContentPartImageImageUrl() - { - } - public ChatImageDetailLevel? Detail { get; set; } + internal InternalChatCompletionRequestMessageContentPartImageImageUrl() + { } -} + public ChatImageDetailLevel? Detail { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageType.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageType.cs index 2a110001..22f41479 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageType.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartImageType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalChatCompletionRequestMessageContentPartImageType : IEquatable { - internal readonly partial struct InternalChatCompletionRequestMessageContentPartImageType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalChatCompletionRequestMessageContentPartImageType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalChatCompletionRequestMessageContentPartImageType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ImageUrlValue = "image_url"; + private const string ImageUrlValue = "image_url"; - public static InternalChatCompletionRequestMessageContentPartImageType ImageUrl { get; } = new InternalChatCompletionRequestMessageContentPartImageType(ImageUrlValue); - public static bool operator ==(InternalChatCompletionRequestMessageContentPartImageType left, InternalChatCompletionRequestMessageContentPartImageType right) => left.Equals(right); - public static bool operator !=(InternalChatCompletionRequestMessageContentPartImageType left, InternalChatCompletionRequestMessageContentPartImageType right) => !left.Equals(right); - public static implicit operator InternalChatCompletionRequestMessageContentPartImageType(string value) => new InternalChatCompletionRequestMessageContentPartImageType(value); + public static InternalChatCompletionRequestMessageContentPartImageType ImageUrl { get; } = new InternalChatCompletionRequestMessageContentPartImageType(ImageUrlValue); + public static bool operator ==(InternalChatCompletionRequestMessageContentPartImageType left, InternalChatCompletionRequestMessageContentPartImageType right) => left.Equals(right); + public static bool operator !=(InternalChatCompletionRequestMessageContentPartImageType left, InternalChatCompletionRequestMessageContentPartImageType right) => !left.Equals(right); + public static implicit operator InternalChatCompletionRequestMessageContentPartImageType(string value) => new InternalChatCompletionRequestMessageContentPartImageType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalChatCompletionRequestMessageContentPartImageType other && Equals(other); - public bool Equals(InternalChatCompletionRequestMessageContentPartImageType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionRequestMessageContentPartImageType other && Equals(other); + public bool Equals(InternalChatCompletionRequestMessageContentPartImageType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.Serialization.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.Serialization.cs index 093b83c7..fd52d8b5 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartRefusal : IJsonModel { - internal partial class InternalChatCompletionRequestMessageContentPartRefusal : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("refusal") != true) - { - writer.WritePropertyName("refusal"u8); - writer.WriteStringValue(Refusal); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("refusal") != true) + { + writer.WritePropertyName("refusal"u8); + writer.WriteStringValue(Refusal); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionRequestMessageContentPartRefusal IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionRequestMessageContentPartRefusal IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionRequestMessageContentPartRefusal(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support reading '{format}' format."); } - internal static InternalChatCompletionRequestMessageContentPartRefusal DeserializeInternalChatCompletionRequestMessageContentPartRefusal(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionRequestMessageContentPartRefusal(document.RootElement, options); + } + + internal static InternalChatCompletionRequestMessageContentPartRefusal DeserializeInternalChatCompletionRequestMessageContentPartRefusal(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalChatCompletionRequestMessageContentPartRefusalType type = default; + string refusal = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = new InternalChatCompletionRequestMessageContentPartRefusalType(property.Value.GetString()); + continue; } - InternalChatCompletionRequestMessageContentPartRefusalType type = default; - string refusal = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("refusal"u8)) { - if (property.NameEquals("type"u8)) - { - type = new InternalChatCompletionRequestMessageContentPartRefusalType(property.Value.GetString()); - continue; - } - if (property.NameEquals("refusal"u8)) - { - refusal = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + refusal = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionRequestMessageContentPartRefusal(type, refusal, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionRequestMessageContentPartRefusal(type, refusal, serializedAdditionalRawData); + } - InternalChatCompletionRequestMessageContentPartRefusal IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionRequestMessageContentPartRefusal(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionRequestMessageContentPartRefusal IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionRequestMessageContentPartRefusal FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionRequestMessageContentPartRefusal(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionRequestMessageContentPartRefusal(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartRefusal)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionRequestMessageContentPartRefusal FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionRequestMessageContentPartRefusal(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.cs index ea0eaa09..44e616cf 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusal.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartRefusal { - internal partial class InternalChatCompletionRequestMessageContentPartRefusal + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionRequestMessageContentPartRefusal(string refusal) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionRequestMessageContentPartRefusal(string refusal) - { - Argument.AssertNotNull(refusal, nameof(refusal)); + Argument.AssertNotNull(refusal, nameof(refusal)); - Refusal = refusal; - } + Refusal = refusal; + } - internal InternalChatCompletionRequestMessageContentPartRefusal(InternalChatCompletionRequestMessageContentPartRefusalType type, string refusal, IDictionary serializedAdditionalRawData) - { - Type = type; - Refusal = refusal; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalChatCompletionRequestMessageContentPartRefusal(InternalChatCompletionRequestMessageContentPartRefusalType type, string refusal, IDictionary serializedAdditionalRawData) + { + Type = type; + Refusal = refusal; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal InternalChatCompletionRequestMessageContentPartRefusal() - { - } + internal InternalChatCompletionRequestMessageContentPartRefusal() + { + } - public InternalChatCompletionRequestMessageContentPartRefusalType Type { get; } = InternalChatCompletionRequestMessageContentPartRefusalType.Refusal; + public InternalChatCompletionRequestMessageContentPartRefusalType Type { get; } = InternalChatCompletionRequestMessageContentPartRefusalType.Refusal; - public string Refusal { get; } - } -} + public string Refusal { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusalType.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusalType.cs index d1c3e849..31dd1eba 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusalType.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartRefusalType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalChatCompletionRequestMessageContentPartRefusalType : IEquatable { - internal readonly partial struct InternalChatCompletionRequestMessageContentPartRefusalType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalChatCompletionRequestMessageContentPartRefusalType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalChatCompletionRequestMessageContentPartRefusalType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string RefusalValue = "refusal"; + private const string RefusalValue = "refusal"; - public static InternalChatCompletionRequestMessageContentPartRefusalType Refusal { get; } = new InternalChatCompletionRequestMessageContentPartRefusalType(RefusalValue); - public static bool operator ==(InternalChatCompletionRequestMessageContentPartRefusalType left, InternalChatCompletionRequestMessageContentPartRefusalType right) => left.Equals(right); - public static bool operator !=(InternalChatCompletionRequestMessageContentPartRefusalType left, InternalChatCompletionRequestMessageContentPartRefusalType right) => !left.Equals(right); - public static implicit operator InternalChatCompletionRequestMessageContentPartRefusalType(string value) => new InternalChatCompletionRequestMessageContentPartRefusalType(value); + public static InternalChatCompletionRequestMessageContentPartRefusalType Refusal { get; } = new InternalChatCompletionRequestMessageContentPartRefusalType(RefusalValue); + public static bool operator ==(InternalChatCompletionRequestMessageContentPartRefusalType left, InternalChatCompletionRequestMessageContentPartRefusalType right) => left.Equals(right); + public static bool operator !=(InternalChatCompletionRequestMessageContentPartRefusalType left, InternalChatCompletionRequestMessageContentPartRefusalType right) => !left.Equals(right); + public static implicit operator InternalChatCompletionRequestMessageContentPartRefusalType(string value) => new InternalChatCompletionRequestMessageContentPartRefusalType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalChatCompletionRequestMessageContentPartRefusalType other && Equals(other); - public bool Equals(InternalChatCompletionRequestMessageContentPartRefusalType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionRequestMessageContentPartRefusalType other && Equals(other); + public bool Equals(InternalChatCompletionRequestMessageContentPartRefusalType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.Serialization.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.Serialization.cs index bec3c465..38af0701 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartText : IJsonModel { - internal partial class InternalChatCompletionRequestMessageContentPartText : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionRequestMessageContentPartText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionRequestMessageContentPartText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionRequestMessageContentPartText(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support reading '{format}' format."); } - internal static InternalChatCompletionRequestMessageContentPartText DeserializeInternalChatCompletionRequestMessageContentPartText(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionRequestMessageContentPartText(document.RootElement, options); + } + + internal static InternalChatCompletionRequestMessageContentPartText DeserializeInternalChatCompletionRequestMessageContentPartText(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalChatCompletionRequestMessageContentPartTextType type = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = new InternalChatCompletionRequestMessageContentPartTextType(property.Value.GetString()); + continue; } - InternalChatCompletionRequestMessageContentPartTextType type = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("text"u8)) { - if (property.NameEquals("type"u8)) - { - type = new InternalChatCompletionRequestMessageContentPartTextType(property.Value.GetString()); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + text = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionRequestMessageContentPartText(type, text, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionRequestMessageContentPartText(type, text, serializedAdditionalRawData); + } - InternalChatCompletionRequestMessageContentPartText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionRequestMessageContentPartText(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionRequestMessageContentPartText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionRequestMessageContentPartText FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionRequestMessageContentPartText(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionRequestMessageContentPartText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionRequestMessageContentPartText)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionRequestMessageContentPartText FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionRequestMessageContentPartText(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.cs index 09645f62..4a8a7d19 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartText.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionRequestMessageContentPartText { - internal partial class InternalChatCompletionRequestMessageContentPartText + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionRequestMessageContentPartText(string text) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionRequestMessageContentPartText(string text) - { - Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(text, nameof(text)); - Text = text; - } + Text = text; + } - internal InternalChatCompletionRequestMessageContentPartText(InternalChatCompletionRequestMessageContentPartTextType type, string text, IDictionary serializedAdditionalRawData) - { - Type = type; - Text = text; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalChatCompletionRequestMessageContentPartText(InternalChatCompletionRequestMessageContentPartTextType type, string text, IDictionary serializedAdditionalRawData) + { + Type = type; + Text = text; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal InternalChatCompletionRequestMessageContentPartText() - { - } + internal InternalChatCompletionRequestMessageContentPartText() + { + } - public InternalChatCompletionRequestMessageContentPartTextType Type { get; } = InternalChatCompletionRequestMessageContentPartTextType.Text; + public InternalChatCompletionRequestMessageContentPartTextType Type { get; } = InternalChatCompletionRequestMessageContentPartTextType.Text; - public string Text { get; } - } -} + public string Text { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartTextType.cs b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartTextType.cs index 8c58795b..d210b04c 100644 --- a/src/Generated/Models/InternalChatCompletionRequestMessageContentPartTextType.cs +++ b/src/Generated/Models/InternalChatCompletionRequestMessageContentPartTextType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalChatCompletionRequestMessageContentPartTextType : IEquatable { - internal readonly partial struct InternalChatCompletionRequestMessageContentPartTextType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalChatCompletionRequestMessageContentPartTextType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalChatCompletionRequestMessageContentPartTextType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TextValue = "text"; + private const string TextValue = "text"; - public static InternalChatCompletionRequestMessageContentPartTextType Text { get; } = new InternalChatCompletionRequestMessageContentPartTextType(TextValue); - public static bool operator ==(InternalChatCompletionRequestMessageContentPartTextType left, InternalChatCompletionRequestMessageContentPartTextType right) => left.Equals(right); - public static bool operator !=(InternalChatCompletionRequestMessageContentPartTextType left, InternalChatCompletionRequestMessageContentPartTextType right) => !left.Equals(right); - public static implicit operator InternalChatCompletionRequestMessageContentPartTextType(string value) => new InternalChatCompletionRequestMessageContentPartTextType(value); + public static InternalChatCompletionRequestMessageContentPartTextType Text { get; } = new InternalChatCompletionRequestMessageContentPartTextType(TextValue); + public static bool operator ==(InternalChatCompletionRequestMessageContentPartTextType left, InternalChatCompletionRequestMessageContentPartTextType right) => left.Equals(right); + public static bool operator !=(InternalChatCompletionRequestMessageContentPartTextType left, InternalChatCompletionRequestMessageContentPartTextType right) => !left.Equals(right); + public static implicit operator InternalChatCompletionRequestMessageContentPartTextType(string value) => new InternalChatCompletionRequestMessageContentPartTextType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalChatCompletionRequestMessageContentPartTextType other && Equals(other); - public bool Equals(InternalChatCompletionRequestMessageContentPartTextType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionRequestMessageContentPartTextType other && Equals(other); + public bool Equals(InternalChatCompletionRequestMessageContentPartTextType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs b/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs index 637df497..49bc76fb 100644 --- a/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionResponseMessage.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionResponseMessage : IJsonModel { - internal partial class InternalChatCompletionResponseMessage : IJsonModel + InternalChatCompletionResponseMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalChatCompletionResponseMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionResponseMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessage)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionResponseMessage(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessage)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - InternalChatCompletionResponseMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionResponseMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessage)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessage)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionResponseMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionResponseMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionResponseMessage(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionResponseMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessage)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionResponseMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionResponseMessage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionResponseMessage.cs b/src/Generated/Models/InternalChatCompletionResponseMessage.cs index f2926221..5d9b9e66 100644 --- a/src/Generated/Models/InternalChatCompletionResponseMessage.cs +++ b/src/Generated/Models/InternalChatCompletionResponseMessage.cs @@ -6,32 +6,31 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionResponseMessage { - internal partial class InternalChatCompletionResponseMessage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalChatCompletionResponseMessage(IEnumerable content, string refusal) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalChatCompletionResponseMessage(IEnumerable content, string refusal) - { - Content = content?.ToList(); - Refusal = refusal; - ToolCalls = new ChangeTrackingList(); - } + Content = content?.ToList(); + Refusal = refusal; + ToolCalls = new ChangeTrackingList(); + } - internal InternalChatCompletionResponseMessage(IReadOnlyList content, string refusal, IReadOnlyList toolCalls, ChatMessageRole role, ChatFunctionCall functionCall, IDictionary serializedAdditionalRawData) - { - Content = content; - Refusal = refusal; - ToolCalls = toolCalls; - Role = role; - FunctionCall = functionCall; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalChatCompletionResponseMessage(IReadOnlyList content, string refusal, IReadOnlyList toolCalls, ChatMessageRole role, ChatFunctionCall functionCall, IDictionary serializedAdditionalRawData) + { + Content = content; + Refusal = refusal; + ToolCalls = toolCalls; + Role = role; + FunctionCall = functionCall; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal InternalChatCompletionResponseMessage() - { - } - public string Refusal { get; } - public IReadOnlyList ToolCalls { get; } + internal InternalChatCompletionResponseMessage() + { } -} + public string Refusal { get; } + public IReadOnlyList ToolCalls { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.Serialization.cs b/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.Serialization.cs index 6cb2512c..fd66542f 100644 --- a/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionResponseMessageFunctionCall : IJsonModel { - internal partial class InternalChatCompletionResponseMessageFunctionCall : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionResponseMessageFunctionCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionResponseMessageFunctionCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionResponseMessageFunctionCall(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support reading '{format}' format."); } - internal static InternalChatCompletionResponseMessageFunctionCall DeserializeInternalChatCompletionResponseMessageFunctionCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionResponseMessageFunctionCall(document.RootElement, options); + } + + internal static InternalChatCompletionResponseMessageFunctionCall DeserializeInternalChatCompletionResponseMessageFunctionCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string arguments = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("arguments"u8)) { - return null; + arguments = property.Value.GetString(); + continue; } - string arguments = default; - string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + name = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionResponseMessageFunctionCall(arguments, name, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionResponseMessageFunctionCall(arguments, name, serializedAdditionalRawData); + } - InternalChatCompletionResponseMessageFunctionCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionResponseMessageFunctionCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionResponseMessageFunctionCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionResponseMessageFunctionCall FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionResponseMessageFunctionCall(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionResponseMessageFunctionCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionResponseMessageFunctionCall)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionResponseMessageFunctionCall FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionResponseMessageFunctionCall(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.cs b/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.cs index 6a070987..eabbd319 100644 --- a/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.cs +++ b/src/Generated/Models/InternalChatCompletionResponseMessageFunctionCall.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionResponseMessageFunctionCall { - internal partial class InternalChatCompletionResponseMessageFunctionCall + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalChatCompletionResponseMessageFunctionCall(string arguments, string name) + { + Argument.AssertNotNull(arguments, nameof(arguments)); + Argument.AssertNotNull(name, nameof(name)); + + Arguments = arguments; + Name = name; + } + + internal InternalChatCompletionResponseMessageFunctionCall(string arguments, string name, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalChatCompletionResponseMessageFunctionCall(string arguments, string name) - { - Argument.AssertNotNull(arguments, nameof(arguments)); - Argument.AssertNotNull(name, nameof(name)); - - Arguments = arguments; - Name = name; - } - - internal InternalChatCompletionResponseMessageFunctionCall(string arguments, string name, IDictionary serializedAdditionalRawData) - { - Arguments = arguments; - Name = name; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalChatCompletionResponseMessageFunctionCall() - { - } - - public string Arguments { get; } - public string Name { get; } + Arguments = arguments; + Name = name; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalChatCompletionResponseMessageFunctionCall() + { + } + + public string Arguments { get; } + public string Name { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionResponseMessageRole.cs b/src/Generated/Models/InternalChatCompletionResponseMessageRole.cs index 0794f101..193b3346 100644 --- a/src/Generated/Models/InternalChatCompletionResponseMessageRole.cs +++ b/src/Generated/Models/InternalChatCompletionResponseMessageRole.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalChatCompletionResponseMessageRole : IEquatable { - internal readonly partial struct InternalChatCompletionResponseMessageRole : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalChatCompletionResponseMessageRole(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalChatCompletionResponseMessageRole(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AssistantValue = "assistant"; + private const string AssistantValue = "assistant"; - public static InternalChatCompletionResponseMessageRole Assistant { get; } = new InternalChatCompletionResponseMessageRole(AssistantValue); - public static bool operator ==(InternalChatCompletionResponseMessageRole left, InternalChatCompletionResponseMessageRole right) => left.Equals(right); - public static bool operator !=(InternalChatCompletionResponseMessageRole left, InternalChatCompletionResponseMessageRole right) => !left.Equals(right); - public static implicit operator InternalChatCompletionResponseMessageRole(string value) => new InternalChatCompletionResponseMessageRole(value); + public static InternalChatCompletionResponseMessageRole Assistant { get; } = new InternalChatCompletionResponseMessageRole(AssistantValue); + public static bool operator ==(InternalChatCompletionResponseMessageRole left, InternalChatCompletionResponseMessageRole right) => left.Equals(right); + public static bool operator !=(InternalChatCompletionResponseMessageRole left, InternalChatCompletionResponseMessageRole right) => !left.Equals(right); + public static implicit operator InternalChatCompletionResponseMessageRole(string value) => new InternalChatCompletionResponseMessageRole(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalChatCompletionResponseMessageRole other && Equals(other); - public bool Equals(InternalChatCompletionResponseMessageRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionResponseMessageRole other && Equals(other); + public bool Equals(InternalChatCompletionResponseMessageRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionStreamOptions.Serialization.cs b/src/Generated/Models/InternalChatCompletionStreamOptions.Serialization.cs index bd3f2eb2..953a5bb3 100644 --- a/src/Generated/Models/InternalChatCompletionStreamOptions.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionStreamOptions.Serialization.cs @@ -8,130 +8,129 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionStreamOptions : IJsonModel { - internal partial class InternalChatCompletionStreamOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("include_usage") != true && Optional.IsDefined(IncludeUsage)) - { - writer.WritePropertyName("include_usage"u8); - writer.WriteBooleanValue(IncludeUsage.Value); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("include_usage") != true && Optional.IsDefined(IncludeUsage)) + { + writer.WritePropertyName("include_usage"u8); + writer.WriteBooleanValue(IncludeUsage.Value); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalChatCompletionStreamOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalChatCompletionStreamOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionStreamOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support reading '{format}' format."); } - internal static InternalChatCompletionStreamOptions DeserializeInternalChatCompletionStreamOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionStreamOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - bool? includeUsage = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalChatCompletionStreamOptions DeserializeInternalChatCompletionStreamOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? includeUsage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("include_usage"u8)) { - if (property.NameEquals("include_usage"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - includeUsage = property.Value.GetBoolean(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + includeUsage = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatCompletionStreamOptions(includeUsage, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatCompletionStreamOptions(includeUsage, serializedAdditionalRawData); + } - InternalChatCompletionStreamOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionStreamOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionStreamOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionStreamOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionStreamOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionStreamOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionStreamOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionStreamOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionStreamOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionStreamOptions.cs b/src/Generated/Models/InternalChatCompletionStreamOptions.cs index 65d1cc3a..2b47c900 100644 --- a/src/Generated/Models/InternalChatCompletionStreamOptions.cs +++ b/src/Generated/Models/InternalChatCompletionStreamOptions.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionStreamOptions { - internal partial class InternalChatCompletionStreamOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalChatCompletionStreamOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalChatCompletionStreamOptions() - { - } - - internal InternalChatCompletionStreamOptions(bool? includeUsage, IDictionary serializedAdditionalRawData) - { - IncludeUsage = includeUsage; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public bool? IncludeUsage { get; set; } + internal InternalChatCompletionStreamOptions(bool? includeUsage, IDictionary serializedAdditionalRawData) + { + IncludeUsage = includeUsage; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public bool? IncludeUsage { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs b/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs index 2a58b56b..a2ff7d2c 100644 --- a/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs +++ b/src/Generated/Models/InternalChatCompletionStreamResponseDelta.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionStreamResponseDelta : IJsonModel { - internal partial class InternalChatCompletionStreamResponseDelta : IJsonModel + InternalChatCompletionStreamResponseDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalChatCompletionStreamResponseDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatCompletionStreamResponseDelta(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatCompletionStreamResponseDelta(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - InternalChatCompletionStreamResponseDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatCompletionStreamResponseDelta(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatCompletionStreamResponseDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalChatCompletionStreamResponseDelta FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatCompletionStreamResponseDelta(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatCompletionStreamResponseDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatCompletionStreamResponseDelta)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalChatCompletionStreamResponseDelta FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatCompletionStreamResponseDelta(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs b/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs index 9bdd14f0..881c2bf9 100644 --- a/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs +++ b/src/Generated/Models/InternalChatCompletionStreamResponseDelta.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatCompletionStreamResponseDelta { - internal partial class InternalChatCompletionStreamResponseDelta - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalChatCompletionStreamResponseDelta(IReadOnlyList content, StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, ChatMessageRole? role, string refusal, IDictionary serializedAdditionalRawData) - { - Content = content; - FunctionCall = functionCall; - ToolCalls = toolCalls; - Role = role; - Refusal = refusal; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public StreamingChatFunctionCallUpdate FunctionCall { get; } - public IReadOnlyList ToolCalls { get; } - public string Refusal { get; } + internal InternalChatCompletionStreamResponseDelta(IReadOnlyList content, StreamingChatFunctionCallUpdate functionCall, IReadOnlyList toolCalls, ChatMessageRole? role, string refusal, IDictionary serializedAdditionalRawData) + { + Content = content; + FunctionCall = functionCall; + ToolCalls = toolCalls; + Role = role; + Refusal = refusal; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public StreamingChatFunctionCallUpdate FunctionCall { get; } + public IReadOnlyList ToolCalls { get; } + public string Refusal { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatCompletionStreamResponseDeltaRole.cs b/src/Generated/Models/InternalChatCompletionStreamResponseDeltaRole.cs index 07df77e4..4bc207f9 100644 --- a/src/Generated/Models/InternalChatCompletionStreamResponseDeltaRole.cs +++ b/src/Generated/Models/InternalChatCompletionStreamResponseDeltaRole.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalChatCompletionStreamResponseDeltaRole : IEquatable { - internal readonly partial struct InternalChatCompletionStreamResponseDeltaRole : IEquatable + private readonly string _value; + + public InternalChatCompletionStreamResponseDeltaRole(string value) { - private readonly string _value; - - public InternalChatCompletionStreamResponseDeltaRole(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string SystemValue = "system"; - private const string UserValue = "user"; - private const string AssistantValue = "assistant"; - private const string ToolValue = "tool"; - - public static InternalChatCompletionStreamResponseDeltaRole System { get; } = new InternalChatCompletionStreamResponseDeltaRole(SystemValue); - public static InternalChatCompletionStreamResponseDeltaRole User { get; } = new InternalChatCompletionStreamResponseDeltaRole(UserValue); - public static InternalChatCompletionStreamResponseDeltaRole Assistant { get; } = new InternalChatCompletionStreamResponseDeltaRole(AssistantValue); - public static InternalChatCompletionStreamResponseDeltaRole Tool { get; } = new InternalChatCompletionStreamResponseDeltaRole(ToolValue); - public static bool operator ==(InternalChatCompletionStreamResponseDeltaRole left, InternalChatCompletionStreamResponseDeltaRole right) => left.Equals(right); - public static bool operator !=(InternalChatCompletionStreamResponseDeltaRole left, InternalChatCompletionStreamResponseDeltaRole right) => !left.Equals(right); - public static implicit operator InternalChatCompletionStreamResponseDeltaRole(string value) => new InternalChatCompletionStreamResponseDeltaRole(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalChatCompletionStreamResponseDeltaRole other && Equals(other); - public bool Equals(InternalChatCompletionStreamResponseDeltaRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string SystemValue = "system"; + private const string UserValue = "user"; + private const string AssistantValue = "assistant"; + private const string ToolValue = "tool"; + + public static InternalChatCompletionStreamResponseDeltaRole System { get; } = new InternalChatCompletionStreamResponseDeltaRole(SystemValue); + public static InternalChatCompletionStreamResponseDeltaRole User { get; } = new InternalChatCompletionStreamResponseDeltaRole(UserValue); + public static InternalChatCompletionStreamResponseDeltaRole Assistant { get; } = new InternalChatCompletionStreamResponseDeltaRole(AssistantValue); + public static InternalChatCompletionStreamResponseDeltaRole Tool { get; } = new InternalChatCompletionStreamResponseDeltaRole(ToolValue); + public static bool operator ==(InternalChatCompletionStreamResponseDeltaRole left, InternalChatCompletionStreamResponseDeltaRole right) => left.Equals(right); + public static bool operator !=(InternalChatCompletionStreamResponseDeltaRole left, InternalChatCompletionStreamResponseDeltaRole right) => !left.Equals(right); + public static implicit operator InternalChatCompletionStreamResponseDeltaRole(string value) => new InternalChatCompletionStreamResponseDeltaRole(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalChatCompletionStreamResponseDeltaRole other && Equals(other); + public bool Equals(InternalChatCompletionStreamResponseDeltaRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatResponseFormatJsonObject.Serialization.cs b/src/Generated/Models/InternalChatResponseFormatJsonObject.Serialization.cs index 3e555b65..96eede94 100644 --- a/src/Generated/Models/InternalChatResponseFormatJsonObject.Serialization.cs +++ b/src/Generated/Models/InternalChatResponseFormatJsonObject.Serialization.cs @@ -8,90 +8,89 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatResponseFormatJsonObject : IJsonModel { - internal partial class InternalChatResponseFormatJsonObject : IJsonModel + InternalChatResponseFormatJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalChatResponseFormatJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatResponseFormatJsonObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonObject)} does not support reading '{format}' format."); } - internal static InternalChatResponseFormatJsonObject DeserializeInternalChatResponseFormatJsonObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatResponseFormatJsonObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatResponseFormatJsonObject(type, serializedAdditionalRawData); - } + internal static InternalChatResponseFormatJsonObject DeserializeInternalChatResponseFormatJsonObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonObject)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalChatResponseFormatJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatResponseFormatJsonObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonObject)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatResponseFormatJsonObject(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalChatResponseFormatJsonObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatResponseFormatJsonObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonObject)} does not support writing '{options.Format}' format."); } + } + + InternalChatResponseFormatJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatResponseFormatJsonObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalChatResponseFormatJsonObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatResponseFormatJsonObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatResponseFormatJsonObject.cs b/src/Generated/Models/InternalChatResponseFormatJsonObject.cs index a3d48940..63405507 100644 --- a/src/Generated/Models/InternalChatResponseFormatJsonObject.cs +++ b/src/Generated/Models/InternalChatResponseFormatJsonObject.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatResponseFormatJsonObject : ChatResponseFormat { - internal partial class InternalChatResponseFormatJsonObject : ChatResponseFormat + public InternalChatResponseFormatJsonObject() { - public InternalChatResponseFormatJsonObject() - { - Type = "json_object"; - } + Type = "json_object"; + } - internal InternalChatResponseFormatJsonObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalChatResponseFormatJsonObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatResponseFormatJsonSchema.Serialization.cs b/src/Generated/Models/InternalChatResponseFormatJsonSchema.Serialization.cs index c2b875ee..429a1da8 100644 --- a/src/Generated/Models/InternalChatResponseFormatJsonSchema.Serialization.cs +++ b/src/Generated/Models/InternalChatResponseFormatJsonSchema.Serialization.cs @@ -9,96 +9,95 @@ using System.Text.Json; using OpenAI.Internal; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatResponseFormatJsonSchema : IJsonModel { - internal partial class InternalChatResponseFormatJsonSchema : IJsonModel + InternalChatResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalChatResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonSchema)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatResponseFormatJsonSchema(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonSchema)} does not support reading '{format}' format."); } - internal static InternalChatResponseFormatJsonSchema DeserializeInternalChatResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatResponseFormatJsonSchema(document.RootElement, options); + } + + internal static InternalChatResponseFormatJsonSchema DeserializeInternalChatResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponseFormatJsonSchemaJsonSchema jsonSchema = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("json_schema"u8)) { - return null; + jsonSchema = InternalResponseFormatJsonSchemaJsonSchema.DeserializeInternalResponseFormatJsonSchemaJsonSchema(property.Value, options); + continue; } - InternalResponseFormatJsonSchemaJsonSchema jsonSchema = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("json_schema"u8)) - { - jsonSchema = InternalResponseFormatJsonSchemaJsonSchema.DeserializeInternalResponseFormatJsonSchemaJsonSchema(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatResponseFormatJsonSchema(type, serializedAdditionalRawData, jsonSchema); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatResponseFormatJsonSchema(type, serializedAdditionalRawData, jsonSchema); + } - InternalChatResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatResponseFormatJsonSchema(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonSchema)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalChatResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalChatResponseFormatJsonSchema FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatResponseFormatJsonSchema(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatResponseFormatJsonSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatResponseFormatJsonSchema)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalChatResponseFormatJsonSchema FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatResponseFormatJsonSchema(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatResponseFormatJsonSchema.cs b/src/Generated/Models/InternalChatResponseFormatJsonSchema.cs index d519acb1..79ba27d7 100644 --- a/src/Generated/Models/InternalChatResponseFormatJsonSchema.cs +++ b/src/Generated/Models/InternalChatResponseFormatJsonSchema.cs @@ -6,27 +6,26 @@ using System.Collections.Generic; using OpenAI.Internal; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatResponseFormatJsonSchema : ChatResponseFormat { - internal partial class InternalChatResponseFormatJsonSchema : ChatResponseFormat + public InternalChatResponseFormatJsonSchema(InternalResponseFormatJsonSchemaJsonSchema jsonSchema) { - public InternalChatResponseFormatJsonSchema(InternalResponseFormatJsonSchemaJsonSchema jsonSchema) - { - Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); - - Type = "json_schema"; - JsonSchema = jsonSchema; - } + Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); - internal InternalChatResponseFormatJsonSchema(string type, IDictionary serializedAdditionalRawData, InternalResponseFormatJsonSchemaJsonSchema jsonSchema) : base(type, serializedAdditionalRawData) - { - JsonSchema = jsonSchema; - } + Type = "json_schema"; + JsonSchema = jsonSchema; + } - internal InternalChatResponseFormatJsonSchema() - { - } + internal InternalChatResponseFormatJsonSchema(string type, IDictionary serializedAdditionalRawData, InternalResponseFormatJsonSchemaJsonSchema jsonSchema) : base(type, serializedAdditionalRawData) + { + JsonSchema = jsonSchema; + } - public InternalResponseFormatJsonSchemaJsonSchema JsonSchema { get; } + internal InternalChatResponseFormatJsonSchema() + { } -} + + public InternalResponseFormatJsonSchemaJsonSchema JsonSchema { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatResponseFormatText.Serialization.cs b/src/Generated/Models/InternalChatResponseFormatText.Serialization.cs index 6ab2655f..a0304d38 100644 --- a/src/Generated/Models/InternalChatResponseFormatText.Serialization.cs +++ b/src/Generated/Models/InternalChatResponseFormatText.Serialization.cs @@ -8,90 +8,89 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatResponseFormatText : IJsonModel { - internal partial class InternalChatResponseFormatText : IJsonModel + InternalChatResponseFormatText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalChatResponseFormatText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalChatResponseFormatText)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalChatResponseFormatText(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalChatResponseFormatText)} does not support reading '{format}' format."); } - internal static InternalChatResponseFormatText DeserializeInternalChatResponseFormatText(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalChatResponseFormatText(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalChatResponseFormatText(type, serializedAdditionalRawData); - } + internal static InternalChatResponseFormatText DeserializeInternalChatResponseFormatText(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalChatResponseFormatText)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalChatResponseFormatText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalChatResponseFormatText(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalChatResponseFormatText)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalChatResponseFormatText(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalChatResponseFormatText FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalChatResponseFormatText(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalChatResponseFormatText)} does not support writing '{options.Format}' format."); } + } + + InternalChatResponseFormatText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalChatResponseFormatText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalChatResponseFormatText)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalChatResponseFormatText FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalChatResponseFormatText(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalChatResponseFormatText.cs b/src/Generated/Models/InternalChatResponseFormatText.cs index 49e7771f..b3221263 100644 --- a/src/Generated/Models/InternalChatResponseFormatText.cs +++ b/src/Generated/Models/InternalChatResponseFormatText.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalChatResponseFormatText : ChatResponseFormat { - internal partial class InternalChatResponseFormatText : ChatResponseFormat + public InternalChatResponseFormatText() { - public InternalChatResponseFormatText() - { - Type = "text"; - } + Type = "text"; + } - internal InternalChatResponseFormatText(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalChatResponseFormatText(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCompleteUploadRequest.Serialization.cs b/src/Generated/Models/InternalCompleteUploadRequest.Serialization.cs index 30ee85a0..bd5eca4d 100644 --- a/src/Generated/Models/InternalCompleteUploadRequest.Serialization.cs +++ b/src/Generated/Models/InternalCompleteUploadRequest.Serialization.cs @@ -8,147 +8,146 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalCompleteUploadRequest : IJsonModel { - internal partial class InternalCompleteUploadRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("part_ids") != true) - { - writer.WritePropertyName("part_ids"u8); - writer.WriteStartArray(); - foreach (var item in PartIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("md5") != true && Optional.IsDefined(Md5)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("part_ids") != true) + { + writer.WritePropertyName("part_ids"u8); + writer.WriteStartArray(); + foreach (var item in PartIds) { - writer.WritePropertyName("md5"u8); - writer.WriteStringValue(Md5); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("md5") != true && Optional.IsDefined(Md5)) + { + writer.WritePropertyName("md5"u8); + writer.WriteStringValue(Md5); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCompleteUploadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCompleteUploadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCompleteUploadRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support reading '{format}' format."); } - internal static InternalCompleteUploadRequest DeserializeInternalCompleteUploadRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCompleteUploadRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList partIds = default; - string md5 = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCompleteUploadRequest DeserializeInternalCompleteUploadRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList partIds = default; + string md5 = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("part_ids"u8)) { - if (property.NameEquals("part_ids"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - partIds = array; - continue; - } - if (property.NameEquals("md5"u8)) - { - md5 = property.Value.GetString(); - continue; - } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + partIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCompleteUploadRequest(partIds, md5, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("md5"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support writing '{options.Format}' format."); + md5 = property.Value.GetString(); + continue; } - } - - InternalCompleteUploadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCompleteUploadRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCompleteUploadRequest(partIds, md5, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCompleteUploadRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCompleteUploadRequest(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalCompleteUploadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCompleteUploadRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCompleteUploadRequest)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCompleteUploadRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCompleteUploadRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCompleteUploadRequest.cs b/src/Generated/Models/InternalCompleteUploadRequest.cs index 74d4d534..90b676e3 100644 --- a/src/Generated/Models/InternalCompleteUploadRequest.cs +++ b/src/Generated/Models/InternalCompleteUploadRequest.cs @@ -6,30 +6,29 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalCompleteUploadRequest { - internal partial class InternalCompleteUploadRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCompleteUploadRequest(IEnumerable partIds) + { + Argument.AssertNotNull(partIds, nameof(partIds)); + + PartIds = partIds.ToList(); + } + + internal InternalCompleteUploadRequest(IList partIds, string md5, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCompleteUploadRequest(IEnumerable partIds) - { - Argument.AssertNotNull(partIds, nameof(partIds)); - - PartIds = partIds.ToList(); - } - - internal InternalCompleteUploadRequest(IList partIds, string md5, IDictionary serializedAdditionalRawData) - { - PartIds = partIds; - Md5 = md5; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCompleteUploadRequest() - { - } - - public IList PartIds { get; } - public string Md5 { get; set; } + PartIds = partIds; + Md5 = md5; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCompleteUploadRequest() + { + } + + public IList PartIds { get; } + public string Md5 { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateAssistantRequestModel.cs b/src/Generated/Models/InternalCreateAssistantRequestModel.cs index dff777d4..b540d18f 100644 --- a/src/Generated/Models/InternalCreateAssistantRequestModel.cs +++ b/src/Generated/Models/InternalCreateAssistantRequestModel.cs @@ -5,74 +5,73 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalCreateAssistantRequestModel : IEquatable { - internal readonly partial struct InternalCreateAssistantRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateAssistantRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateAssistantRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string Gpt4oValue = "gpt-4o"; - private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; - private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; - private const string Gpt4oMiniValue = "gpt-4o-mini"; - private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; - private const string Gpt4TurboValue = "gpt-4-turbo"; - private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; - private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; - private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; - private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; - private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; - private const string Gpt4Value = "gpt-4"; - private const string Gpt40314Value = "gpt-4-0314"; - private const string Gpt40613Value = "gpt-4-0613"; - private const string Gpt432kValue = "gpt-4-32k"; - private const string Gpt432k0314Value = "gpt-4-32k-0314"; - private const string Gpt432k0613Value = "gpt-4-32k-0613"; - private const string Gpt35TurboValue = "gpt-3.5-turbo"; - private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; - private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; - private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; - private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; - private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; + private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; + private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; + private const string Gpt4oMiniValue = "gpt-4o-mini"; + private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; + private const string Gpt4TurboValue = "gpt-4-turbo"; + private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; + private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; + private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; + private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; + private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; + private const string Gpt4Value = "gpt-4"; + private const string Gpt40314Value = "gpt-4-0314"; + private const string Gpt40613Value = "gpt-4-0613"; + private const string Gpt432kValue = "gpt-4-32k"; + private const string Gpt432k0314Value = "gpt-4-32k-0314"; + private const string Gpt432k0613Value = "gpt-4-32k-0613"; + private const string Gpt35TurboValue = "gpt-3.5-turbo"; + private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; + private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; + private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; + private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; + private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; - public static InternalCreateAssistantRequestModel Gpt4o { get; } = new InternalCreateAssistantRequestModel(Gpt4oValue); - public static InternalCreateAssistantRequestModel Gpt4o20240806 { get; } = new InternalCreateAssistantRequestModel(Gpt4o20240806Value); - public static InternalCreateAssistantRequestModel Gpt4o20240513 { get; } = new InternalCreateAssistantRequestModel(Gpt4o20240513Value); - public static InternalCreateAssistantRequestModel Gpt4oMini { get; } = new InternalCreateAssistantRequestModel(Gpt4oMiniValue); - public static InternalCreateAssistantRequestModel Gpt4oMini20240718 { get; } = new InternalCreateAssistantRequestModel(Gpt4oMini20240718Value); - public static InternalCreateAssistantRequestModel Gpt4Turbo { get; } = new InternalCreateAssistantRequestModel(Gpt4TurboValue); - public static InternalCreateAssistantRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateAssistantRequestModel(Gpt4Turbo20240409Value); - public static InternalCreateAssistantRequestModel Gpt40125Preview { get; } = new InternalCreateAssistantRequestModel(Gpt40125PreviewValue); - public static InternalCreateAssistantRequestModel Gpt4TurboPreview { get; } = new InternalCreateAssistantRequestModel(Gpt4TurboPreviewValue); - public static InternalCreateAssistantRequestModel Gpt41106Preview { get; } = new InternalCreateAssistantRequestModel(Gpt41106PreviewValue); - public static InternalCreateAssistantRequestModel Gpt4VisionPreview { get; } = new InternalCreateAssistantRequestModel(Gpt4VisionPreviewValue); - public static InternalCreateAssistantRequestModel Gpt4 { get; } = new InternalCreateAssistantRequestModel(Gpt4Value); - public static InternalCreateAssistantRequestModel Gpt40314 { get; } = new InternalCreateAssistantRequestModel(Gpt40314Value); - public static InternalCreateAssistantRequestModel Gpt40613 { get; } = new InternalCreateAssistantRequestModel(Gpt40613Value); - public static InternalCreateAssistantRequestModel Gpt432k { get; } = new InternalCreateAssistantRequestModel(Gpt432kValue); - public static InternalCreateAssistantRequestModel Gpt432k0314 { get; } = new InternalCreateAssistantRequestModel(Gpt432k0314Value); - public static InternalCreateAssistantRequestModel Gpt432k0613 { get; } = new InternalCreateAssistantRequestModel(Gpt432k0613Value); - public static InternalCreateAssistantRequestModel Gpt35Turbo { get; } = new InternalCreateAssistantRequestModel(Gpt35TurboValue); - public static InternalCreateAssistantRequestModel Gpt35Turbo16k { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo16kValue); - public static InternalCreateAssistantRequestModel Gpt35Turbo0613 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo0613Value); - public static InternalCreateAssistantRequestModel Gpt35Turbo1106 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo1106Value); - public static InternalCreateAssistantRequestModel Gpt35Turbo0125 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo0125Value); - public static InternalCreateAssistantRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo16k0613Value); - public static bool operator ==(InternalCreateAssistantRequestModel left, InternalCreateAssistantRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateAssistantRequestModel left, InternalCreateAssistantRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateAssistantRequestModel(string value) => new InternalCreateAssistantRequestModel(value); + public static InternalCreateAssistantRequestModel Gpt4o { get; } = new InternalCreateAssistantRequestModel(Gpt4oValue); + public static InternalCreateAssistantRequestModel Gpt4o20240806 { get; } = new InternalCreateAssistantRequestModel(Gpt4o20240806Value); + public static InternalCreateAssistantRequestModel Gpt4o20240513 { get; } = new InternalCreateAssistantRequestModel(Gpt4o20240513Value); + public static InternalCreateAssistantRequestModel Gpt4oMini { get; } = new InternalCreateAssistantRequestModel(Gpt4oMiniValue); + public static InternalCreateAssistantRequestModel Gpt4oMini20240718 { get; } = new InternalCreateAssistantRequestModel(Gpt4oMini20240718Value); + public static InternalCreateAssistantRequestModel Gpt4Turbo { get; } = new InternalCreateAssistantRequestModel(Gpt4TurboValue); + public static InternalCreateAssistantRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateAssistantRequestModel(Gpt4Turbo20240409Value); + public static InternalCreateAssistantRequestModel Gpt40125Preview { get; } = new InternalCreateAssistantRequestModel(Gpt40125PreviewValue); + public static InternalCreateAssistantRequestModel Gpt4TurboPreview { get; } = new InternalCreateAssistantRequestModel(Gpt4TurboPreviewValue); + public static InternalCreateAssistantRequestModel Gpt41106Preview { get; } = new InternalCreateAssistantRequestModel(Gpt41106PreviewValue); + public static InternalCreateAssistantRequestModel Gpt4VisionPreview { get; } = new InternalCreateAssistantRequestModel(Gpt4VisionPreviewValue); + public static InternalCreateAssistantRequestModel Gpt4 { get; } = new InternalCreateAssistantRequestModel(Gpt4Value); + public static InternalCreateAssistantRequestModel Gpt40314 { get; } = new InternalCreateAssistantRequestModel(Gpt40314Value); + public static InternalCreateAssistantRequestModel Gpt40613 { get; } = new InternalCreateAssistantRequestModel(Gpt40613Value); + public static InternalCreateAssistantRequestModel Gpt432k { get; } = new InternalCreateAssistantRequestModel(Gpt432kValue); + public static InternalCreateAssistantRequestModel Gpt432k0314 { get; } = new InternalCreateAssistantRequestModel(Gpt432k0314Value); + public static InternalCreateAssistantRequestModel Gpt432k0613 { get; } = new InternalCreateAssistantRequestModel(Gpt432k0613Value); + public static InternalCreateAssistantRequestModel Gpt35Turbo { get; } = new InternalCreateAssistantRequestModel(Gpt35TurboValue); + public static InternalCreateAssistantRequestModel Gpt35Turbo16k { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo16kValue); + public static InternalCreateAssistantRequestModel Gpt35Turbo0613 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo0613Value); + public static InternalCreateAssistantRequestModel Gpt35Turbo1106 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo1106Value); + public static InternalCreateAssistantRequestModel Gpt35Turbo0125 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo0125Value); + public static InternalCreateAssistantRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateAssistantRequestModel(Gpt35Turbo16k0613Value); + public static bool operator ==(InternalCreateAssistantRequestModel left, InternalCreateAssistantRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateAssistantRequestModel left, InternalCreateAssistantRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateAssistantRequestModel(string value) => new InternalCreateAssistantRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateAssistantRequestModel other && Equals(other); - public bool Equals(InternalCreateAssistantRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateAssistantRequestModel other && Equals(other); + public bool Equals(InternalCreateAssistantRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateAssistantRequestToolResources.Serialization.cs b/src/Generated/Models/InternalCreateAssistantRequestToolResources.Serialization.cs index d21e1612..606ac4d0 100644 --- a/src/Generated/Models/InternalCreateAssistantRequestToolResources.Serialization.cs +++ b/src/Generated/Models/InternalCreateAssistantRequestToolResources.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateAssistantRequestToolResources : IJsonModel { - internal partial class InternalCreateAssistantRequestToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateAssistantRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateAssistantRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateAssistantRequestToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support reading '{format}' format."); } - internal static InternalCreateAssistantRequestToolResources DeserializeInternalCreateAssistantRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateAssistantRequestToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalCreateAssistantRequestToolResourcesCodeInterpreter codeInterpreter = default; - FileSearchToolResources fileSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateAssistantRequestToolResources DeserializeInternalCreateAssistantRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateAssistantRequestToolResourcesCodeInterpreter codeInterpreter = default; + FileSearchToolResources fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("code_interpreter"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = InternalCreateAssistantRequestToolResourcesCodeInterpreter.DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(property.Value, options); continue; } - if (property.NameEquals("file_search"u8)) + codeInterpreter = InternalCreateAssistantRequestToolResourcesCodeInterpreter.DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = FileSearchToolResources.DeserializeFileSearchToolResources(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = FileSearchToolResources.DeserializeFileSearchToolResources(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateAssistantRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateAssistantRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); + } - InternalCreateAssistantRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateAssistantRequestToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateAssistantRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateAssistantRequestToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateAssistantRequestToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateAssistantRequestToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateAssistantRequestToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateAssistantRequestToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateAssistantRequestToolResources.cs b/src/Generated/Models/InternalCreateAssistantRequestToolResources.cs index 3ac5aa73..55b6435d 100644 --- a/src/Generated/Models/InternalCreateAssistantRequestToolResources.cs +++ b/src/Generated/Models/InternalCreateAssistantRequestToolResources.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateAssistantRequestToolResources { - internal partial class InternalCreateAssistantRequestToolResources + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateAssistantRequestToolResources() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateAssistantRequestToolResources() - { - } - - internal InternalCreateAssistantRequestToolResources(InternalCreateAssistantRequestToolResourcesCodeInterpreter codeInterpreter, FileSearchToolResources fileSearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalCreateAssistantRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } - public FileSearchToolResources FileSearch { get; set; } + internal InternalCreateAssistantRequestToolResources(InternalCreateAssistantRequestToolResourcesCodeInterpreter codeInterpreter, FileSearchToolResources fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalCreateAssistantRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } + public FileSearchToolResources FileSearch { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.Serialization.cs index ea159b98..e1fb5bb0 100644 --- a/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateAssistantRequestToolResourcesCodeInterpreter : IJsonModel { - internal partial class InternalCreateAssistantRequestToolResourcesCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateAssistantRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateAssistantRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalCreateAssistantRequestToolResourcesCodeInterpreter DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateAssistantRequestToolResourcesCodeInterpreter DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + fileIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateAssistantRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateAssistantRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalCreateAssistantRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateAssistantRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateAssistantRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateAssistantRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateAssistantRequestToolResourcesCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.cs b/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.cs index ee042f14..fba92ee4 100644 --- a/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.cs +++ b/src/Generated/Models/InternalCreateAssistantRequestToolResourcesCodeInterpreter.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateAssistantRequestToolResourcesCodeInterpreter { - internal partial class InternalCreateAssistantRequestToolResourcesCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateAssistantRequestToolResourcesCodeInterpreter() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateAssistantRequestToolResourcesCodeInterpreter() - { - FileIds = new ChangeTrackingList(); - } - - internal InternalCreateAssistantRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + } - public IList FileIds { get; } + internal InternalCreateAssistantRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList FileIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs b/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs index 3fb6cc73..f8ca01ae 100644 --- a/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateBatchRequest.Serialization.cs @@ -8,181 +8,180 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalCreateBatchRequest : IJsonModel { - internal partial class InternalCreateBatchRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("input_file_id") != true) - { - writer.WritePropertyName("input_file_id"u8); - writer.WriteStringValue(InputFileId); - } - if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("input_file_id") != true) + { + writer.WritePropertyName("input_file_id"u8); + writer.WriteStringValue(InputFileId); + } + if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) + { + writer.WritePropertyName("endpoint"u8); + writer.WriteStringValue(Endpoint.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("completion_window") != true) + { + writer.WritePropertyName("completion_window"u8); + writer.WriteStringValue(CompletionWindow.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - writer.WritePropertyName("endpoint"u8); - writer.WriteStringValue(Endpoint.ToString()); + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("completion_window") != true) + else { - writer.WritePropertyName("completion_window"u8); - writer.WriteStringValue(CompletionWindow.ToString()); + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("metadata"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateBatchRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateBatchRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateBatchRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support reading '{format}' format."); } - internal static InternalCreateBatchRequest DeserializeInternalCreateBatchRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateBatchRequest(document.RootElement, options); + } + + internal static InternalCreateBatchRequest DeserializeInternalCreateBatchRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string inputFileId = default; + InternalCreateBatchRequestEndpoint endpoint = default; + InternalBatchCompletionTimeframe completionWindow = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input_file_id"u8)) { - return null; + inputFileId = property.Value.GetString(); + continue; } - string inputFileId = default; - InternalCreateBatchRequestEndpoint endpoint = default; - InternalBatchCompletionTimeframe completionWindow = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("endpoint"u8)) { - if (property.NameEquals("input_file_id"u8)) - { - inputFileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("endpoint"u8)) - { - endpoint = new InternalCreateBatchRequestEndpoint(property.Value.GetString()); - continue; - } - if (property.NameEquals("completion_window"u8)) - { - completionWindow = new InternalBatchCompletionTimeframe(property.Value.GetString()); - continue; - } - if (property.NameEquals("metadata"u8)) + endpoint = new InternalCreateBatchRequestEndpoint(property.Value.GetString()); + continue; + } + if (property.NameEquals("completion_window"u8)) + { + completionWindow = new InternalBatchCompletionTimeframe(property.Value.GetString()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateBatchRequest(inputFileId, endpoint, completionWindow, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateBatchRequest(inputFileId, endpoint, completionWindow, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - InternalCreateBatchRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateBatchRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateBatchRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateBatchRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateBatchRequest(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateBatchRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateBatchRequest)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateBatchRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateBatchRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateBatchRequest.cs b/src/Generated/Models/InternalCreateBatchRequest.cs index 4b5db4d7..a1739d11 100644 --- a/src/Generated/Models/InternalCreateBatchRequest.cs +++ b/src/Generated/Models/InternalCreateBatchRequest.cs @@ -5,37 +5,36 @@ using System; using System.Collections.Generic; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalCreateBatchRequest { - internal partial class InternalCreateBatchRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateBatchRequest(string inputFileId, InternalCreateBatchRequestEndpoint endpoint) + { + Argument.AssertNotNull(inputFileId, nameof(inputFileId)); + + InputFileId = inputFileId; + Endpoint = endpoint; + Metadata = new ChangeTrackingDictionary(); + } + + internal InternalCreateBatchRequest(string inputFileId, InternalCreateBatchRequestEndpoint endpoint, InternalBatchCompletionTimeframe completionWindow, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateBatchRequest(string inputFileId, InternalCreateBatchRequestEndpoint endpoint) - { - Argument.AssertNotNull(inputFileId, nameof(inputFileId)); - - InputFileId = inputFileId; - Endpoint = endpoint; - Metadata = new ChangeTrackingDictionary(); - } - - internal InternalCreateBatchRequest(string inputFileId, InternalCreateBatchRequestEndpoint endpoint, InternalBatchCompletionTimeframe completionWindow, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - InputFileId = inputFileId; - Endpoint = endpoint; - CompletionWindow = completionWindow; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateBatchRequest() - { - } - - public string InputFileId { get; } - public InternalCreateBatchRequestEndpoint Endpoint { get; } - public InternalBatchCompletionTimeframe CompletionWindow { get; } = InternalBatchCompletionTimeframe._24h; - - public IReadOnlyDictionary Metadata { get; } + InputFileId = inputFileId; + Endpoint = endpoint; + CompletionWindow = completionWindow; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateBatchRequest() + { + } + + public string InputFileId { get; } + public InternalCreateBatchRequestEndpoint Endpoint { get; } + public InternalBatchCompletionTimeframe CompletionWindow { get; } = InternalBatchCompletionTimeframe._24h; + + public IReadOnlyDictionary Metadata { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateBatchRequestEndpoint.cs b/src/Generated/Models/InternalCreateBatchRequestEndpoint.cs index 9163b9de..e747eb12 100644 --- a/src/Generated/Models/InternalCreateBatchRequestEndpoint.cs +++ b/src/Generated/Models/InternalCreateBatchRequestEndpoint.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal readonly partial struct InternalCreateBatchRequestEndpoint : IEquatable { - internal readonly partial struct InternalCreateBatchRequestEndpoint : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateBatchRequestEndpoint(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateBatchRequestEndpoint(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string V1ChatCompletionsValue = "/v1/chat/completions"; - private const string V1EmbeddingsValue = "/v1/embeddings"; + private const string V1ChatCompletionsValue = "/v1/chat/completions"; + private const string V1EmbeddingsValue = "/v1/embeddings"; - public static InternalCreateBatchRequestEndpoint V1ChatCompletions { get; } = new InternalCreateBatchRequestEndpoint(V1ChatCompletionsValue); - public static InternalCreateBatchRequestEndpoint V1Embeddings { get; } = new InternalCreateBatchRequestEndpoint(V1EmbeddingsValue); - public static bool operator ==(InternalCreateBatchRequestEndpoint left, InternalCreateBatchRequestEndpoint right) => left.Equals(right); - public static bool operator !=(InternalCreateBatchRequestEndpoint left, InternalCreateBatchRequestEndpoint right) => !left.Equals(right); - public static implicit operator InternalCreateBatchRequestEndpoint(string value) => new InternalCreateBatchRequestEndpoint(value); + public static InternalCreateBatchRequestEndpoint V1ChatCompletions { get; } = new InternalCreateBatchRequestEndpoint(V1ChatCompletionsValue); + public static InternalCreateBatchRequestEndpoint V1Embeddings { get; } = new InternalCreateBatchRequestEndpoint(V1EmbeddingsValue); + public static bool operator ==(InternalCreateBatchRequestEndpoint left, InternalCreateBatchRequestEndpoint right) => left.Equals(right); + public static bool operator !=(InternalCreateBatchRequestEndpoint left, InternalCreateBatchRequestEndpoint right) => !left.Equals(right); + public static implicit operator InternalCreateBatchRequestEndpoint(string value) => new InternalCreateBatchRequestEndpoint(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateBatchRequestEndpoint other && Equals(other); - public bool Equals(InternalCreateBatchRequestEndpoint other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateBatchRequestEndpoint other && Equals(other); + public bool Equals(InternalCreateBatchRequestEndpoint other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.Serialization.cs index a5999bf8..f54e1d65 100644 --- a/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.Serialization.cs @@ -8,214 +8,213 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionFunctionResponse : IJsonModel { - internal partial class InternalCreateChatCompletionFunctionResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + { + writer.WritePropertyName("choices"u8); + writer.WriteStartArray(); + foreach (var item in Choices) { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("created") != true) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(Created, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) + { + writer.WritePropertyName("system_fingerprint"u8); + writer.WriteStringValue(SystemFingerprint); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("choices"u8); - writer.WriteStartArray(); - foreach (var item in Choices) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("created") != true) - { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(Created, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); - } - if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) - { - writer.WritePropertyName("system_fingerprint"u8); - writer.WriteStringValue(SystemFingerprint); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) - { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateChatCompletionFunctionResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateChatCompletionFunctionResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateChatCompletionFunctionResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support reading '{format}' format."); } - internal static InternalCreateChatCompletionFunctionResponse DeserializeInternalCreateChatCompletionFunctionResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateChatCompletionFunctionResponse(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalCreateChatCompletionFunctionResponse DeserializeInternalCreateChatCompletionFunctionResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IReadOnlyList choices = default; + DateTimeOffset created = default; + string model = default; + string systemFingerprint = default; + InternalCreateChatCompletionFunctionResponseObject @object = default; + ChatTokenUsage usage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - IReadOnlyList choices = default; - DateTimeOffset created = default; - string model = default; - string systemFingerprint = default; - InternalCreateChatCompletionFunctionResponseObject @object = default; - ChatTokenUsage usage = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("choices"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("choices"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalCreateChatCompletionFunctionResponseChoice.DeserializeInternalCreateChatCompletionFunctionResponseChoice(item, options)); - } - choices = array; - continue; + array.Add(InternalCreateChatCompletionFunctionResponseChoice.DeserializeInternalCreateChatCompletionFunctionResponseChoice(item, options)); } - if (property.NameEquals("created"u8)) - { - created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("system_fingerprint"u8)) - { - systemFingerprint = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalCreateChatCompletionFunctionResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("usage"u8)) + choices = array; + continue; + } + if (property.NameEquals("created"u8)) + { + created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("system_fingerprint"u8)) + { + systemFingerprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalCreateChatCompletionFunctionResponseObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateChatCompletionFunctionResponse( - id, - choices, - created, - model, - systemFingerprint, - @object, - usage, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateChatCompletionFunctionResponse( + id, + choices, + created, + model, + systemFingerprint, + @object, + usage, + serializedAdditionalRawData); + } - InternalCreateChatCompletionFunctionResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateChatCompletionFunctionResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateChatCompletionFunctionResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateChatCompletionFunctionResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateChatCompletionFunctionResponse(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateChatCompletionFunctionResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponse)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateChatCompletionFunctionResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateChatCompletionFunctionResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.cs b/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.cs index 19c62120..636f6dc1 100644 --- a/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.cs +++ b/src/Generated/Models/InternalCreateChatCompletionFunctionResponse.cs @@ -6,46 +6,45 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionFunctionResponse { - internal partial class InternalCreateChatCompletionFunctionResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateChatCompletionFunctionResponse(string id, IEnumerable choices, DateTimeOffset created, string model) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateChatCompletionFunctionResponse(string id, IEnumerable choices, DateTimeOffset created, string model) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(choices, nameof(choices)); - Argument.AssertNotNull(model, nameof(model)); - - Id = id; - Choices = choices.ToList(); - Created = created; - Model = model; - } - - internal InternalCreateChatCompletionFunctionResponse(string id, IReadOnlyList choices, DateTimeOffset created, string model, string systemFingerprint, InternalCreateChatCompletionFunctionResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) - { - Id = id; - Choices = choices; - Created = created; - Model = model; - SystemFingerprint = systemFingerprint; - Object = @object; - Usage = usage; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateChatCompletionFunctionResponse() - { - } - - public string Id { get; } - public IReadOnlyList Choices { get; } - public DateTimeOffset Created { get; } - public string Model { get; } - public string SystemFingerprint { get; } - public InternalCreateChatCompletionFunctionResponseObject Object { get; } = InternalCreateChatCompletionFunctionResponseObject.ChatCompletion; - - public ChatTokenUsage Usage { get; } + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(choices, nameof(choices)); + Argument.AssertNotNull(model, nameof(model)); + + Id = id; + Choices = choices.ToList(); + Created = created; + Model = model; } -} + + internal InternalCreateChatCompletionFunctionResponse(string id, IReadOnlyList choices, DateTimeOffset created, string model, string systemFingerprint, InternalCreateChatCompletionFunctionResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) + { + Id = id; + Choices = choices; + Created = created; + Model = model; + SystemFingerprint = systemFingerprint; + Object = @object; + Usage = usage; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalCreateChatCompletionFunctionResponse() + { + } + + public string Id { get; } + public IReadOnlyList Choices { get; } + public DateTimeOffset Created { get; } + public string Model { get; } + public string SystemFingerprint { get; } + public InternalCreateChatCompletionFunctionResponseObject Object { get; } = InternalCreateChatCompletionFunctionResponseObject.ChatCompletion; + + public ChatTokenUsage Usage { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.Serialization.cs index 55422fd8..3060964c 100644 --- a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionFunctionResponseChoice : IJsonModel { - internal partial class InternalCreateChatCompletionFunctionResponseChoice : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("finish_reason") != true) - { - writer.WritePropertyName("finish_reason"u8); - writer.WriteStringValue(FinishReason.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) - { - writer.WritePropertyName("message"u8); - writer.WriteObjectValue(Message, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("finish_reason") != true) + { + writer.WritePropertyName("finish_reason"u8); + writer.WriteStringValue(FinishReason.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteObjectValue(Message, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateChatCompletionFunctionResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateChatCompletionFunctionResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateChatCompletionFunctionResponseChoice(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support reading '{format}' format."); } - internal static InternalCreateChatCompletionFunctionResponseChoice DeserializeInternalCreateChatCompletionFunctionResponseChoice(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateChatCompletionFunctionResponseChoice(document.RootElement, options); + } + + internal static InternalCreateChatCompletionFunctionResponseChoice DeserializeInternalCreateChatCompletionFunctionResponseChoice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateChatCompletionFunctionResponseChoiceFinishReason finishReason = default; + int index = default; + InternalChatCompletionResponseMessage message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("finish_reason"u8)) { - return null; + finishReason = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(property.Value.GetString()); + continue; } - InternalCreateChatCompletionFunctionResponseChoiceFinishReason finishReason = default; - int index = default; - InternalChatCompletionResponseMessage message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("index"u8)) { - if (property.NameEquals("finish_reason"u8)) - { - finishReason = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(property.Value.GetString()); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = InternalChatCompletionResponseMessage.DeserializeInternalChatCompletionResponseMessage(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + index = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateChatCompletionFunctionResponseChoice(finishReason, index, message, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("message"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support writing '{options.Format}' format."); + message = InternalChatCompletionResponseMessage.DeserializeInternalChatCompletionResponseMessage(property.Value, options); + continue; } - } - - InternalCreateChatCompletionFunctionResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateChatCompletionFunctionResponseChoice(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateChatCompletionFunctionResponseChoice(finishReason, index, message, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateChatCompletionFunctionResponseChoice FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateChatCompletionFunctionResponseChoice(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support writing '{options.Format}' format."); } + } + + InternalCreateChatCompletionFunctionResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateChatCompletionFunctionResponseChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionFunctionResponseChoice)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateChatCompletionFunctionResponseChoice FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateChatCompletionFunctionResponseChoice(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.cs b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.cs index 6e0687de..8019049c 100644 --- a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.cs +++ b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoice.cs @@ -5,34 +5,33 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionFunctionResponseChoice { - internal partial class InternalCreateChatCompletionFunctionResponseChoice + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateChatCompletionFunctionResponseChoice(InternalCreateChatCompletionFunctionResponseChoiceFinishReason finishReason, int index, InternalChatCompletionResponseMessage message) + { + Argument.AssertNotNull(message, nameof(message)); + + FinishReason = finishReason; + Index = index; + Message = message; + } + + internal InternalCreateChatCompletionFunctionResponseChoice(InternalCreateChatCompletionFunctionResponseChoiceFinishReason finishReason, int index, InternalChatCompletionResponseMessage message, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateChatCompletionFunctionResponseChoice(InternalCreateChatCompletionFunctionResponseChoiceFinishReason finishReason, int index, InternalChatCompletionResponseMessage message) - { - Argument.AssertNotNull(message, nameof(message)); - - FinishReason = finishReason; - Index = index; - Message = message; - } - - internal InternalCreateChatCompletionFunctionResponseChoice(InternalCreateChatCompletionFunctionResponseChoiceFinishReason finishReason, int index, InternalChatCompletionResponseMessage message, IDictionary serializedAdditionalRawData) - { - FinishReason = finishReason; - Index = index; - Message = message; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateChatCompletionFunctionResponseChoice() - { - } - - public InternalCreateChatCompletionFunctionResponseChoiceFinishReason FinishReason { get; } - public int Index { get; } - public InternalChatCompletionResponseMessage Message { get; } + FinishReason = finishReason; + Index = index; + Message = message; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateChatCompletionFunctionResponseChoice() + { + } + + public InternalCreateChatCompletionFunctionResponseChoiceFinishReason FinishReason { get; } + public int Index { get; } + public InternalChatCompletionResponseMessage Message { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoiceFinishReason.cs b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoiceFinishReason.cs index 679edf97..2b388a3b 100644 --- a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoiceFinishReason.cs +++ b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseChoiceFinishReason.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionFunctionResponseChoiceFinishReason : IEquatable { - internal readonly partial struct InternalCreateChatCompletionFunctionResponseChoiceFinishReason : IEquatable + private readonly string _value; + + public InternalCreateChatCompletionFunctionResponseChoiceFinishReason(string value) { - private readonly string _value; - - public InternalCreateChatCompletionFunctionResponseChoiceFinishReason(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string StopValue = "stop"; - private const string LengthValue = "length"; - private const string FunctionCallValue = "function_call"; - private const string ContentFilterValue = "content_filter"; - - public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason Stop { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(StopValue); - public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason Length { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(LengthValue); - public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason FunctionCall { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(FunctionCallValue); - public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason ContentFilter { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(ContentFilterValue); - public static bool operator ==(InternalCreateChatCompletionFunctionResponseChoiceFinishReason left, InternalCreateChatCompletionFunctionResponseChoiceFinishReason right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionFunctionResponseChoiceFinishReason left, InternalCreateChatCompletionFunctionResponseChoiceFinishReason right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionFunctionResponseChoiceFinishReason(string value) => new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionFunctionResponseChoiceFinishReason other && Equals(other); - public bool Equals(InternalCreateChatCompletionFunctionResponseChoiceFinishReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string StopValue = "stop"; + private const string LengthValue = "length"; + private const string FunctionCallValue = "function_call"; + private const string ContentFilterValue = "content_filter"; + + public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason Stop { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(StopValue); + public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason Length { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(LengthValue); + public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason FunctionCall { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(FunctionCallValue); + public static InternalCreateChatCompletionFunctionResponseChoiceFinishReason ContentFilter { get; } = new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(ContentFilterValue); + public static bool operator ==(InternalCreateChatCompletionFunctionResponseChoiceFinishReason left, InternalCreateChatCompletionFunctionResponseChoiceFinishReason right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionFunctionResponseChoiceFinishReason left, InternalCreateChatCompletionFunctionResponseChoiceFinishReason right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionFunctionResponseChoiceFinishReason(string value) => new InternalCreateChatCompletionFunctionResponseChoiceFinishReason(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionFunctionResponseChoiceFinishReason other && Equals(other); + public bool Equals(InternalCreateChatCompletionFunctionResponseChoiceFinishReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseObject.cs b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseObject.cs index 43c04df1..3402e6a0 100644 --- a/src/Generated/Models/InternalCreateChatCompletionFunctionResponseObject.cs +++ b/src/Generated/Models/InternalCreateChatCompletionFunctionResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionFunctionResponseObject : IEquatable { - internal readonly partial struct InternalCreateChatCompletionFunctionResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateChatCompletionFunctionResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateChatCompletionFunctionResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ChatCompletionValue = "chat.completion"; + private const string ChatCompletionValue = "chat.completion"; - public static InternalCreateChatCompletionFunctionResponseObject ChatCompletion { get; } = new InternalCreateChatCompletionFunctionResponseObject(ChatCompletionValue); - public static bool operator ==(InternalCreateChatCompletionFunctionResponseObject left, InternalCreateChatCompletionFunctionResponseObject right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionFunctionResponseObject left, InternalCreateChatCompletionFunctionResponseObject right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionFunctionResponseObject(string value) => new InternalCreateChatCompletionFunctionResponseObject(value); + public static InternalCreateChatCompletionFunctionResponseObject ChatCompletion { get; } = new InternalCreateChatCompletionFunctionResponseObject(ChatCompletionValue); + public static bool operator ==(InternalCreateChatCompletionFunctionResponseObject left, InternalCreateChatCompletionFunctionResponseObject right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionFunctionResponseObject left, InternalCreateChatCompletionFunctionResponseObject right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionFunctionResponseObject(string value) => new InternalCreateChatCompletionFunctionResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionFunctionResponseObject other && Equals(other); - public bool Equals(InternalCreateChatCompletionFunctionResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionFunctionResponseObject other && Equals(other); + public bool Equals(InternalCreateChatCompletionFunctionResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs b/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs index f01b6a49..839fe010 100644 --- a/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs +++ b/src/Generated/Models/InternalCreateChatCompletionRequestModel.cs @@ -5,86 +5,85 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionRequestModel : IEquatable { - internal readonly partial struct InternalCreateChatCompletionRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateChatCompletionRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateChatCompletionRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string O1PreviewValue = "o1-preview"; - private const string O1Preview20240912Value = "o1-preview-2024-09-12"; - private const string O1MiniValue = "o1-mini"; - private const string O1Mini20240912Value = "o1-mini-2024-09-12"; - private const string Gpt4oValue = "gpt-4o"; - private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; - private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; - private const string Chatgpt4oLatestValue = "chatgpt-4o-latest"; - private const string Gpt4oMiniValue = "gpt-4o-mini"; - private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; - private const string Gpt4TurboValue = "gpt-4-turbo"; - private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; - private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; - private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; - private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; - private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; - private const string Gpt4Value = "gpt-4"; - private const string Gpt40314Value = "gpt-4-0314"; - private const string Gpt40613Value = "gpt-4-0613"; - private const string Gpt432kValue = "gpt-4-32k"; - private const string Gpt432k0314Value = "gpt-4-32k-0314"; - private const string Gpt432k0613Value = "gpt-4-32k-0613"; - private const string Gpt35TurboValue = "gpt-3.5-turbo"; - private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; - private const string Gpt35Turbo0301Value = "gpt-3.5-turbo-0301"; - private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; - private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; - private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; - private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; + private const string O1PreviewValue = "o1-preview"; + private const string O1Preview20240912Value = "o1-preview-2024-09-12"; + private const string O1MiniValue = "o1-mini"; + private const string O1Mini20240912Value = "o1-mini-2024-09-12"; + private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; + private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; + private const string Chatgpt4oLatestValue = "chatgpt-4o-latest"; + private const string Gpt4oMiniValue = "gpt-4o-mini"; + private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; + private const string Gpt4TurboValue = "gpt-4-turbo"; + private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; + private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; + private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; + private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; + private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; + private const string Gpt4Value = "gpt-4"; + private const string Gpt40314Value = "gpt-4-0314"; + private const string Gpt40613Value = "gpt-4-0613"; + private const string Gpt432kValue = "gpt-4-32k"; + private const string Gpt432k0314Value = "gpt-4-32k-0314"; + private const string Gpt432k0613Value = "gpt-4-32k-0613"; + private const string Gpt35TurboValue = "gpt-3.5-turbo"; + private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; + private const string Gpt35Turbo0301Value = "gpt-3.5-turbo-0301"; + private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; + private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; + private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; + private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; - public static InternalCreateChatCompletionRequestModel O1Preview { get; } = new InternalCreateChatCompletionRequestModel(O1PreviewValue); - public static InternalCreateChatCompletionRequestModel O1Preview20240912 { get; } = new InternalCreateChatCompletionRequestModel(O1Preview20240912Value); - public static InternalCreateChatCompletionRequestModel O1Mini { get; } = new InternalCreateChatCompletionRequestModel(O1MiniValue); - public static InternalCreateChatCompletionRequestModel O1Mini20240912 { get; } = new InternalCreateChatCompletionRequestModel(O1Mini20240912Value); - public static InternalCreateChatCompletionRequestModel Gpt4o { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oValue); - public static InternalCreateChatCompletionRequestModel Gpt4o20240806 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4o20240806Value); - public static InternalCreateChatCompletionRequestModel Gpt4o20240513 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4o20240513Value); - public static InternalCreateChatCompletionRequestModel Chatgpt4oLatest { get; } = new InternalCreateChatCompletionRequestModel(Chatgpt4oLatestValue); - public static InternalCreateChatCompletionRequestModel Gpt4oMini { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMiniValue); - public static InternalCreateChatCompletionRequestModel Gpt4oMini20240718 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMini20240718Value); - public static InternalCreateChatCompletionRequestModel Gpt4Turbo { get; } = new InternalCreateChatCompletionRequestModel(Gpt4TurboValue); - public static InternalCreateChatCompletionRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4Turbo20240409Value); - public static InternalCreateChatCompletionRequestModel Gpt40125Preview { get; } = new InternalCreateChatCompletionRequestModel(Gpt40125PreviewValue); - public static InternalCreateChatCompletionRequestModel Gpt4TurboPreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4TurboPreviewValue); - public static InternalCreateChatCompletionRequestModel Gpt41106Preview { get; } = new InternalCreateChatCompletionRequestModel(Gpt41106PreviewValue); - public static InternalCreateChatCompletionRequestModel Gpt4VisionPreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4VisionPreviewValue); - public static InternalCreateChatCompletionRequestModel Gpt4 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4Value); - public static InternalCreateChatCompletionRequestModel Gpt40314 { get; } = new InternalCreateChatCompletionRequestModel(Gpt40314Value); - public static InternalCreateChatCompletionRequestModel Gpt40613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt40613Value); - public static InternalCreateChatCompletionRequestModel Gpt432k { get; } = new InternalCreateChatCompletionRequestModel(Gpt432kValue); - public static InternalCreateChatCompletionRequestModel Gpt432k0314 { get; } = new InternalCreateChatCompletionRequestModel(Gpt432k0314Value); - public static InternalCreateChatCompletionRequestModel Gpt432k0613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt432k0613Value); - public static InternalCreateChatCompletionRequestModel Gpt35Turbo { get; } = new InternalCreateChatCompletionRequestModel(Gpt35TurboValue); - public static InternalCreateChatCompletionRequestModel Gpt35Turbo16k { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo16kValue); - public static InternalCreateChatCompletionRequestModel Gpt35Turbo0301 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo0301Value); - public static InternalCreateChatCompletionRequestModel Gpt35Turbo0613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo0613Value); - public static InternalCreateChatCompletionRequestModel Gpt35Turbo1106 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo1106Value); - public static InternalCreateChatCompletionRequestModel Gpt35Turbo0125 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo0125Value); - public static InternalCreateChatCompletionRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo16k0613Value); - public static bool operator ==(InternalCreateChatCompletionRequestModel left, InternalCreateChatCompletionRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionRequestModel left, InternalCreateChatCompletionRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionRequestModel(string value) => new InternalCreateChatCompletionRequestModel(value); + public static InternalCreateChatCompletionRequestModel O1Preview { get; } = new InternalCreateChatCompletionRequestModel(O1PreviewValue); + public static InternalCreateChatCompletionRequestModel O1Preview20240912 { get; } = new InternalCreateChatCompletionRequestModel(O1Preview20240912Value); + public static InternalCreateChatCompletionRequestModel O1Mini { get; } = new InternalCreateChatCompletionRequestModel(O1MiniValue); + public static InternalCreateChatCompletionRequestModel O1Mini20240912 { get; } = new InternalCreateChatCompletionRequestModel(O1Mini20240912Value); + public static InternalCreateChatCompletionRequestModel Gpt4o { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oValue); + public static InternalCreateChatCompletionRequestModel Gpt4o20240806 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4o20240806Value); + public static InternalCreateChatCompletionRequestModel Gpt4o20240513 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4o20240513Value); + public static InternalCreateChatCompletionRequestModel Chatgpt4oLatest { get; } = new InternalCreateChatCompletionRequestModel(Chatgpt4oLatestValue); + public static InternalCreateChatCompletionRequestModel Gpt4oMini { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMiniValue); + public static InternalCreateChatCompletionRequestModel Gpt4oMini20240718 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4oMini20240718Value); + public static InternalCreateChatCompletionRequestModel Gpt4Turbo { get; } = new InternalCreateChatCompletionRequestModel(Gpt4TurboValue); + public static InternalCreateChatCompletionRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4Turbo20240409Value); + public static InternalCreateChatCompletionRequestModel Gpt40125Preview { get; } = new InternalCreateChatCompletionRequestModel(Gpt40125PreviewValue); + public static InternalCreateChatCompletionRequestModel Gpt4TurboPreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4TurboPreviewValue); + public static InternalCreateChatCompletionRequestModel Gpt41106Preview { get; } = new InternalCreateChatCompletionRequestModel(Gpt41106PreviewValue); + public static InternalCreateChatCompletionRequestModel Gpt4VisionPreview { get; } = new InternalCreateChatCompletionRequestModel(Gpt4VisionPreviewValue); + public static InternalCreateChatCompletionRequestModel Gpt4 { get; } = new InternalCreateChatCompletionRequestModel(Gpt4Value); + public static InternalCreateChatCompletionRequestModel Gpt40314 { get; } = new InternalCreateChatCompletionRequestModel(Gpt40314Value); + public static InternalCreateChatCompletionRequestModel Gpt40613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt40613Value); + public static InternalCreateChatCompletionRequestModel Gpt432k { get; } = new InternalCreateChatCompletionRequestModel(Gpt432kValue); + public static InternalCreateChatCompletionRequestModel Gpt432k0314 { get; } = new InternalCreateChatCompletionRequestModel(Gpt432k0314Value); + public static InternalCreateChatCompletionRequestModel Gpt432k0613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt432k0613Value); + public static InternalCreateChatCompletionRequestModel Gpt35Turbo { get; } = new InternalCreateChatCompletionRequestModel(Gpt35TurboValue); + public static InternalCreateChatCompletionRequestModel Gpt35Turbo16k { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo16kValue); + public static InternalCreateChatCompletionRequestModel Gpt35Turbo0301 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo0301Value); + public static InternalCreateChatCompletionRequestModel Gpt35Turbo0613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo0613Value); + public static InternalCreateChatCompletionRequestModel Gpt35Turbo1106 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo1106Value); + public static InternalCreateChatCompletionRequestModel Gpt35Turbo0125 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo0125Value); + public static InternalCreateChatCompletionRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateChatCompletionRequestModel(Gpt35Turbo16k0613Value); + public static bool operator ==(InternalCreateChatCompletionRequestModel left, InternalCreateChatCompletionRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionRequestModel left, InternalCreateChatCompletionRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionRequestModel(string value) => new InternalCreateChatCompletionRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionRequestModel other && Equals(other); - public bool Equals(InternalCreateChatCompletionRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionRequestModel other && Equals(other); + public bool Equals(InternalCreateChatCompletionRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionRequestServiceTier.cs b/src/Generated/Models/InternalCreateChatCompletionRequestServiceTier.cs index 7d6f7f65..5b4c3dca 100644 --- a/src/Generated/Models/InternalCreateChatCompletionRequestServiceTier.cs +++ b/src/Generated/Models/InternalCreateChatCompletionRequestServiceTier.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionRequestServiceTier : IEquatable { - internal readonly partial struct InternalCreateChatCompletionRequestServiceTier : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateChatCompletionRequestServiceTier(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateChatCompletionRequestServiceTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; - private const string DefaultValue = "default"; + private const string AutoValue = "auto"; + private const string DefaultValue = "default"; - public static InternalCreateChatCompletionRequestServiceTier Auto { get; } = new InternalCreateChatCompletionRequestServiceTier(AutoValue); - public static InternalCreateChatCompletionRequestServiceTier Default { get; } = new InternalCreateChatCompletionRequestServiceTier(DefaultValue); - public static bool operator ==(InternalCreateChatCompletionRequestServiceTier left, InternalCreateChatCompletionRequestServiceTier right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionRequestServiceTier left, InternalCreateChatCompletionRequestServiceTier right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionRequestServiceTier(string value) => new InternalCreateChatCompletionRequestServiceTier(value); + public static InternalCreateChatCompletionRequestServiceTier Auto { get; } = new InternalCreateChatCompletionRequestServiceTier(AutoValue); + public static InternalCreateChatCompletionRequestServiceTier Default { get; } = new InternalCreateChatCompletionRequestServiceTier(DefaultValue); + public static bool operator ==(InternalCreateChatCompletionRequestServiceTier left, InternalCreateChatCompletionRequestServiceTier right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionRequestServiceTier left, InternalCreateChatCompletionRequestServiceTier right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionRequestServiceTier(string value) => new InternalCreateChatCompletionRequestServiceTier(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionRequestServiceTier other && Equals(other); - public bool Equals(InternalCreateChatCompletionRequestServiceTier other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionRequestServiceTier other && Equals(other); + public bool Equals(InternalCreateChatCompletionRequestServiceTier other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionRequestToolChoice.cs b/src/Generated/Models/InternalCreateChatCompletionRequestToolChoice.cs index 04328dce..43baf6f8 100644 --- a/src/Generated/Models/InternalCreateChatCompletionRequestToolChoice.cs +++ b/src/Generated/Models/InternalCreateChatCompletionRequestToolChoice.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionRequestToolChoice : IEquatable { - internal readonly partial struct InternalCreateChatCompletionRequestToolChoice : IEquatable + private readonly string _value; + + public InternalCreateChatCompletionRequestToolChoice(string value) { - private readonly string _value; - - public InternalCreateChatCompletionRequestToolChoice(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string NoneValue = "none"; - private const string AutoValue = "auto"; - private const string RequiredValue = "required"; - - public static InternalCreateChatCompletionRequestToolChoice None { get; } = new InternalCreateChatCompletionRequestToolChoice(NoneValue); - public static InternalCreateChatCompletionRequestToolChoice Auto { get; } = new InternalCreateChatCompletionRequestToolChoice(AutoValue); - public static InternalCreateChatCompletionRequestToolChoice Required { get; } = new InternalCreateChatCompletionRequestToolChoice(RequiredValue); - public static bool operator ==(InternalCreateChatCompletionRequestToolChoice left, InternalCreateChatCompletionRequestToolChoice right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionRequestToolChoice left, InternalCreateChatCompletionRequestToolChoice right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionRequestToolChoice(string value) => new InternalCreateChatCompletionRequestToolChoice(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionRequestToolChoice other && Equals(other); - public bool Equals(InternalCreateChatCompletionRequestToolChoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string NoneValue = "none"; + private const string AutoValue = "auto"; + private const string RequiredValue = "required"; + + public static InternalCreateChatCompletionRequestToolChoice None { get; } = new InternalCreateChatCompletionRequestToolChoice(NoneValue); + public static InternalCreateChatCompletionRequestToolChoice Auto { get; } = new InternalCreateChatCompletionRequestToolChoice(AutoValue); + public static InternalCreateChatCompletionRequestToolChoice Required { get; } = new InternalCreateChatCompletionRequestToolChoice(RequiredValue); + public static bool operator ==(InternalCreateChatCompletionRequestToolChoice left, InternalCreateChatCompletionRequestToolChoice right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionRequestToolChoice left, InternalCreateChatCompletionRequestToolChoice right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionRequestToolChoice(string value) => new InternalCreateChatCompletionRequestToolChoice(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionRequestToolChoice other && Equals(other); + public bool Equals(InternalCreateChatCompletionRequestToolChoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionResponseChoice.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionResponseChoice.Serialization.cs index dc72c0a8..04adadfe 100644 --- a/src/Generated/Models/InternalCreateChatCompletionResponseChoice.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionResponseChoice.Serialization.cs @@ -8,171 +8,170 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionResponseChoice : IJsonModel { - internal partial class InternalCreateChatCompletionResponseChoice : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("finish_reason") != true) - { - writer.WritePropertyName("finish_reason"u8); - writer.WriteStringValue(FinishReason.ToSerialString()); - } - if (SerializedAdditionalRawData?.ContainsKey("index") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("finish_reason") != true) + { + writer.WritePropertyName("finish_reason"u8); + writer.WriteStringValue(FinishReason.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteObjectValue(Message, options); + } + if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true) + { + if (Logprobs != null) { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); + writer.WritePropertyName("logprobs"u8); + writer.WriteObjectValue(Logprobs, options); } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) + else { - writer.WritePropertyName("message"u8); - writer.WriteObjectValue(Message, options); + writer.WriteNull("logprobs"); } - if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Logprobs != null) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WritePropertyName("logprobs"u8); - writer.WriteObjectValue(Logprobs, options); - } - else - { - writer.WriteNull("logprobs"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateChatCompletionResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateChatCompletionResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateChatCompletionResponseChoice(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support reading '{format}' format."); } - internal static InternalCreateChatCompletionResponseChoice DeserializeInternalCreateChatCompletionResponseChoice(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateChatCompletionResponseChoice(document.RootElement, options); + } + + internal static InternalCreateChatCompletionResponseChoice DeserializeInternalCreateChatCompletionResponseChoice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatFinishReason finishReason = default; + int index = default; + InternalChatCompletionResponseMessage message = default; + InternalCreateChatCompletionResponseChoiceLogprobs logprobs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("finish_reason"u8)) { - return null; + finishReason = property.Value.GetString().ToChatFinishReason(); + continue; } - ChatFinishReason finishReason = default; - int index = default; - InternalChatCompletionResponseMessage message = default; - InternalCreateChatCompletionResponseChoiceLogprobs logprobs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("index"u8)) { - if (property.NameEquals("finish_reason"u8)) - { - finishReason = property.Value.GetString().ToChatFinishReason(); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("message"u8)) - { - message = InternalChatCompletionResponseMessage.DeserializeInternalChatCompletionResponseMessage(property.Value, options); - continue; - } - if (property.NameEquals("logprobs"u8)) + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = InternalChatCompletionResponseMessage.DeserializeInternalChatCompletionResponseMessage(property.Value, options); + continue; + } + if (property.NameEquals("logprobs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - logprobs = null; - continue; - } - logprobs = InternalCreateChatCompletionResponseChoiceLogprobs.DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(property.Value, options); + logprobs = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + logprobs = InternalCreateChatCompletionResponseChoiceLogprobs.DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateChatCompletionResponseChoice(finishReason, index, message, logprobs, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateChatCompletionResponseChoice(finishReason, index, message, logprobs, serializedAdditionalRawData); + } - InternalCreateChatCompletionResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateChatCompletionResponseChoice(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateChatCompletionResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateChatCompletionResponseChoice FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateChatCompletionResponseChoice(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateChatCompletionResponseChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoice)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateChatCompletionResponseChoice FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateChatCompletionResponseChoice(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionResponseChoice.cs b/src/Generated/Models/InternalCreateChatCompletionResponseChoice.cs index 88a8051c..a1f7356d 100644 --- a/src/Generated/Models/InternalCreateChatCompletionResponseChoice.cs +++ b/src/Generated/Models/InternalCreateChatCompletionResponseChoice.cs @@ -5,37 +5,36 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionResponseChoice { - internal partial class InternalCreateChatCompletionResponseChoice + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateChatCompletionResponseChoice(ChatFinishReason finishReason, int index, InternalChatCompletionResponseMessage message, InternalCreateChatCompletionResponseChoiceLogprobs logprobs) + { + Argument.AssertNotNull(message, nameof(message)); + + FinishReason = finishReason; + Index = index; + Message = message; + Logprobs = logprobs; + } + + internal InternalCreateChatCompletionResponseChoice(ChatFinishReason finishReason, int index, InternalChatCompletionResponseMessage message, InternalCreateChatCompletionResponseChoiceLogprobs logprobs, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateChatCompletionResponseChoice(ChatFinishReason finishReason, int index, InternalChatCompletionResponseMessage message, InternalCreateChatCompletionResponseChoiceLogprobs logprobs) - { - Argument.AssertNotNull(message, nameof(message)); - - FinishReason = finishReason; - Index = index; - Message = message; - Logprobs = logprobs; - } - - internal InternalCreateChatCompletionResponseChoice(ChatFinishReason finishReason, int index, InternalChatCompletionResponseMessage message, InternalCreateChatCompletionResponseChoiceLogprobs logprobs, IDictionary serializedAdditionalRawData) - { - FinishReason = finishReason; - Index = index; - Message = message; - Logprobs = logprobs; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateChatCompletionResponseChoice() - { - } - - public ChatFinishReason FinishReason { get; } - public int Index { get; } - public InternalChatCompletionResponseMessage Message { get; } - public InternalCreateChatCompletionResponseChoiceLogprobs Logprobs { get; } + FinishReason = finishReason; + Index = index; + Message = message; + Logprobs = logprobs; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateChatCompletionResponseChoice() + { + } + + public ChatFinishReason FinishReason { get; } + public int Index { get; } + public InternalChatCompletionResponseMessage Message { get; } + public InternalCreateChatCompletionResponseChoiceLogprobs Logprobs { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.Serialization.cs index 1098a70f..1f5ca780 100644 --- a/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.Serialization.cs @@ -8,181 +8,180 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionResponseChoiceLogprobs : IJsonModel { - internal partial class InternalCreateChatCompletionResponseChoiceLogprobs : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("content") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("content") != true) + { + if (Content != null && Optional.IsCollectionDefined(Content)) { - if (Content != null && Optional.IsCollectionDefined(Content)) - { - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (var item in Content) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) { - writer.WriteNull("content"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("refusal") != true) + else { - if (Refusal != null && Optional.IsCollectionDefined(Refusal)) - { - writer.WritePropertyName("refusal"u8); - writer.WriteStartArray(); - foreach (var item in Refusal) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else + writer.WriteNull("content"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("refusal") != true) + { + if (Refusal != null && Optional.IsCollectionDefined(Refusal)) + { + writer.WritePropertyName("refusal"u8); + writer.WriteStartArray(); + foreach (var item in Refusal) { - writer.WriteNull("refusal"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("refusal"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateChatCompletionResponseChoiceLogprobs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateChatCompletionResponseChoiceLogprobs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support reading '{format}' format."); } - internal static InternalCreateChatCompletionResponseChoiceLogprobs DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList content = default; - IReadOnlyList refusal = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateChatCompletionResponseChoiceLogprobs DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList content = default; + IReadOnlyList refusal = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("content"u8)) { - if (property.NameEquals("content"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - content = new ChangeTrackingList(); - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); - } - content = array; + content = new ChangeTrackingList(); continue; } - if (property.NameEquals("refusal"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("refusal"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - refusal = new ChangeTrackingList(); - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); - } - refusal = array; + refusal = new ChangeTrackingList(); continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); } + refusal = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateChatCompletionResponseChoiceLogprobs(content, refusal, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateChatCompletionResponseChoiceLogprobs(content, refusal, serializedAdditionalRawData); + } - InternalCreateChatCompletionResponseChoiceLogprobs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateChatCompletionResponseChoiceLogprobs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateChatCompletionResponseChoiceLogprobs FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionResponseChoiceLogprobs)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateChatCompletionResponseChoiceLogprobs FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateChatCompletionResponseChoiceLogprobs(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.cs b/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.cs index 236f4909..d4e1993d 100644 --- a/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.cs +++ b/src/Generated/Models/InternalCreateChatCompletionResponseChoiceLogprobs.cs @@ -6,29 +6,28 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionResponseChoiceLogprobs { - internal partial class InternalCreateChatCompletionResponseChoiceLogprobs + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateChatCompletionResponseChoiceLogprobs(IEnumerable content, IEnumerable refusal) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateChatCompletionResponseChoiceLogprobs(IEnumerable content, IEnumerable refusal) - { - Content = content?.ToList(); - Refusal = refusal?.ToList(); - } - - internal InternalCreateChatCompletionResponseChoiceLogprobs(IReadOnlyList content, IReadOnlyList refusal, IDictionary serializedAdditionalRawData) - { - Content = content; - Refusal = refusal; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Content = content?.ToList(); + Refusal = refusal?.ToList(); + } - internal InternalCreateChatCompletionResponseChoiceLogprobs() - { - } + internal InternalCreateChatCompletionResponseChoiceLogprobs(IReadOnlyList content, IReadOnlyList refusal, IDictionary serializedAdditionalRawData) + { + Content = content; + Refusal = refusal; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public IReadOnlyList Content { get; } - public IReadOnlyList Refusal { get; } + internal InternalCreateChatCompletionResponseChoiceLogprobs() + { } -} + + public IReadOnlyList Content { get; } + public IReadOnlyList Refusal { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionResponseObject.cs b/src/Generated/Models/InternalCreateChatCompletionResponseObject.cs index 9c1c590e..7cc6a25f 100644 --- a/src/Generated/Models/InternalCreateChatCompletionResponseObject.cs +++ b/src/Generated/Models/InternalCreateChatCompletionResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionResponseObject : IEquatable { - internal readonly partial struct InternalCreateChatCompletionResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateChatCompletionResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateChatCompletionResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ChatCompletionValue = "chat.completion"; + private const string ChatCompletionValue = "chat.completion"; - public static InternalCreateChatCompletionResponseObject ChatCompletion { get; } = new InternalCreateChatCompletionResponseObject(ChatCompletionValue); - public static bool operator ==(InternalCreateChatCompletionResponseObject left, InternalCreateChatCompletionResponseObject right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionResponseObject left, InternalCreateChatCompletionResponseObject right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionResponseObject(string value) => new InternalCreateChatCompletionResponseObject(value); + public static InternalCreateChatCompletionResponseObject ChatCompletion { get; } = new InternalCreateChatCompletionResponseObject(ChatCompletionValue); + public static bool operator ==(InternalCreateChatCompletionResponseObject left, InternalCreateChatCompletionResponseObject right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionResponseObject left, InternalCreateChatCompletionResponseObject right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionResponseObject(string value) => new InternalCreateChatCompletionResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionResponseObject other && Equals(other); - public bool Equals(InternalCreateChatCompletionResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionResponseObject other && Equals(other); + public bool Equals(InternalCreateChatCompletionResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionResponseServiceTier.cs b/src/Generated/Models/InternalCreateChatCompletionResponseServiceTier.cs index 599297be..a1bbd92d 100644 --- a/src/Generated/Models/InternalCreateChatCompletionResponseServiceTier.cs +++ b/src/Generated/Models/InternalCreateChatCompletionResponseServiceTier.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionResponseServiceTier : IEquatable { - internal readonly partial struct InternalCreateChatCompletionResponseServiceTier : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateChatCompletionResponseServiceTier(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateChatCompletionResponseServiceTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ScaleValue = "scale"; - private const string DefaultValue = "default"; + private const string ScaleValue = "scale"; + private const string DefaultValue = "default"; - public static InternalCreateChatCompletionResponseServiceTier Scale { get; } = new InternalCreateChatCompletionResponseServiceTier(ScaleValue); - public static InternalCreateChatCompletionResponseServiceTier Default { get; } = new InternalCreateChatCompletionResponseServiceTier(DefaultValue); - public static bool operator ==(InternalCreateChatCompletionResponseServiceTier left, InternalCreateChatCompletionResponseServiceTier right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionResponseServiceTier left, InternalCreateChatCompletionResponseServiceTier right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionResponseServiceTier(string value) => new InternalCreateChatCompletionResponseServiceTier(value); + public static InternalCreateChatCompletionResponseServiceTier Scale { get; } = new InternalCreateChatCompletionResponseServiceTier(ScaleValue); + public static InternalCreateChatCompletionResponseServiceTier Default { get; } = new InternalCreateChatCompletionResponseServiceTier(DefaultValue); + public static bool operator ==(InternalCreateChatCompletionResponseServiceTier left, InternalCreateChatCompletionResponseServiceTier right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionResponseServiceTier left, InternalCreateChatCompletionResponseServiceTier right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionResponseServiceTier(string value) => new InternalCreateChatCompletionResponseServiceTier(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionResponseServiceTier other && Equals(other); - public bool Equals(InternalCreateChatCompletionResponseServiceTier other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionResponseServiceTier other && Equals(other); + public bool Equals(InternalCreateChatCompletionResponseServiceTier other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs index fd1dd8a1..c1c9aafd 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionStreamResponseChoice : IJsonModel { - internal partial class InternalCreateChatCompletionStreamResponseChoice : IJsonModel + InternalCreateChatCompletionStreamResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalCreateChatCompletionStreamResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoice)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateChatCompletionStreamResponseChoice(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoice)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateChatCompletionStreamResponseChoice(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoice)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - InternalCreateChatCompletionStreamResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateChatCompletionStreamResponseChoice(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoice)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoice)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateChatCompletionStreamResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateChatCompletionStreamResponseChoice FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateChatCompletionStreamResponseChoice(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateChatCompletionStreamResponseChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoice)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateChatCompletionStreamResponseChoice FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateChatCompletionStreamResponseChoice(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.cs index 6bb376d9..1dbd37cf 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoice.cs @@ -5,35 +5,34 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionStreamResponseChoice { - internal partial class InternalCreateChatCompletionStreamResponseChoice + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateChatCompletionStreamResponseChoice(InternalChatCompletionStreamResponseDelta delta, ChatFinishReason? finishReason, int index) + { + Argument.AssertNotNull(delta, nameof(delta)); + + Delta = delta; + FinishReason = finishReason; + Index = index; + } + + internal InternalCreateChatCompletionStreamResponseChoice(InternalChatCompletionStreamResponseDelta delta, InternalCreateChatCompletionStreamResponseChoiceLogprobs logprobs, ChatFinishReason? finishReason, int index, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateChatCompletionStreamResponseChoice(InternalChatCompletionStreamResponseDelta delta, ChatFinishReason? finishReason, int index) - { - Argument.AssertNotNull(delta, nameof(delta)); - - Delta = delta; - FinishReason = finishReason; - Index = index; - } - - internal InternalCreateChatCompletionStreamResponseChoice(InternalChatCompletionStreamResponseDelta delta, InternalCreateChatCompletionStreamResponseChoiceLogprobs logprobs, ChatFinishReason? finishReason, int index, IDictionary serializedAdditionalRawData) - { - Delta = delta; - Logprobs = logprobs; - FinishReason = finishReason; - Index = index; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateChatCompletionStreamResponseChoice() - { - } - - public InternalChatCompletionStreamResponseDelta Delta { get; } - public InternalCreateChatCompletionStreamResponseChoiceLogprobs Logprobs { get; } - public int Index { get; } + Delta = delta; + Logprobs = logprobs; + FinishReason = finishReason; + Index = index; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateChatCompletionStreamResponseChoice() + { + } + + public InternalChatCompletionStreamResponseDelta Delta { get; } + public InternalCreateChatCompletionStreamResponseChoiceLogprobs Logprobs { get; } + public int Index { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceFinishReason.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceFinishReason.cs index 76fdf5a2..a2dd50ea 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceFinishReason.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceFinishReason.cs @@ -5,38 +5,37 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionStreamResponseChoiceFinishReason : IEquatable { - internal readonly partial struct InternalCreateChatCompletionStreamResponseChoiceFinishReason : IEquatable + private readonly string _value; + + public InternalCreateChatCompletionStreamResponseChoiceFinishReason(string value) { - private readonly string _value; - - public InternalCreateChatCompletionStreamResponseChoiceFinishReason(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string StopValue = "stop"; - private const string LengthValue = "length"; - private const string ToolCallsValue = "tool_calls"; - private const string ContentFilterValue = "content_filter"; - private const string FunctionCallValue = "function_call"; - - public static InternalCreateChatCompletionStreamResponseChoiceFinishReason Stop { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(StopValue); - public static InternalCreateChatCompletionStreamResponseChoiceFinishReason Length { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(LengthValue); - public static InternalCreateChatCompletionStreamResponseChoiceFinishReason ToolCalls { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(ToolCallsValue); - public static InternalCreateChatCompletionStreamResponseChoiceFinishReason ContentFilter { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(ContentFilterValue); - public static InternalCreateChatCompletionStreamResponseChoiceFinishReason FunctionCall { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(FunctionCallValue); - public static bool operator ==(InternalCreateChatCompletionStreamResponseChoiceFinishReason left, InternalCreateChatCompletionStreamResponseChoiceFinishReason right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionStreamResponseChoiceFinishReason left, InternalCreateChatCompletionStreamResponseChoiceFinishReason right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionStreamResponseChoiceFinishReason(string value) => new InternalCreateChatCompletionStreamResponseChoiceFinishReason(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionStreamResponseChoiceFinishReason other && Equals(other); - public bool Equals(InternalCreateChatCompletionStreamResponseChoiceFinishReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string StopValue = "stop"; + private const string LengthValue = "length"; + private const string ToolCallsValue = "tool_calls"; + private const string ContentFilterValue = "content_filter"; + private const string FunctionCallValue = "function_call"; + + public static InternalCreateChatCompletionStreamResponseChoiceFinishReason Stop { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(StopValue); + public static InternalCreateChatCompletionStreamResponseChoiceFinishReason Length { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(LengthValue); + public static InternalCreateChatCompletionStreamResponseChoiceFinishReason ToolCalls { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(ToolCallsValue); + public static InternalCreateChatCompletionStreamResponseChoiceFinishReason ContentFilter { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(ContentFilterValue); + public static InternalCreateChatCompletionStreamResponseChoiceFinishReason FunctionCall { get; } = new InternalCreateChatCompletionStreamResponseChoiceFinishReason(FunctionCallValue); + public static bool operator ==(InternalCreateChatCompletionStreamResponseChoiceFinishReason left, InternalCreateChatCompletionStreamResponseChoiceFinishReason right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionStreamResponseChoiceFinishReason left, InternalCreateChatCompletionStreamResponseChoiceFinishReason right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionStreamResponseChoiceFinishReason(string value) => new InternalCreateChatCompletionStreamResponseChoiceFinishReason(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionStreamResponseChoiceFinishReason other && Equals(other); + public bool Equals(InternalCreateChatCompletionStreamResponseChoiceFinishReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.Serialization.cs index 02337c27..a16243f3 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.Serialization.cs @@ -8,181 +8,180 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionStreamResponseChoiceLogprobs : IJsonModel { - internal partial class InternalCreateChatCompletionStreamResponseChoiceLogprobs : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("content") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("content") != true) + { + if (Content != null && Optional.IsCollectionDefined(Content)) { - if (Content != null && Optional.IsCollectionDefined(Content)) - { - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (var item in Content) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) { - writer.WriteNull("content"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("refusal") != true) + else { - if (Refusal != null && Optional.IsCollectionDefined(Refusal)) - { - writer.WritePropertyName("refusal"u8); - writer.WriteStartArray(); - foreach (var item in Refusal) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else + writer.WriteNull("content"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("refusal") != true) + { + if (Refusal != null && Optional.IsCollectionDefined(Refusal)) + { + writer.WritePropertyName("refusal"u8); + writer.WriteStartArray(); + foreach (var item in Refusal) { - writer.WriteNull("refusal"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("refusal"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateChatCompletionStreamResponseChoiceLogprobs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateChatCompletionStreamResponseChoiceLogprobs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support reading '{format}' format."); } - internal static InternalCreateChatCompletionStreamResponseChoiceLogprobs DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList content = default; - IReadOnlyList refusal = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateChatCompletionStreamResponseChoiceLogprobs DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList content = default; + IReadOnlyList refusal = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("content"u8)) { - if (property.NameEquals("content"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - content = new ChangeTrackingList(); - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); - } - content = array; + content = new ChangeTrackingList(); continue; } - if (property.NameEquals("refusal"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); + } + content = array; + continue; + } + if (property.NameEquals("refusal"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - refusal = new ChangeTrackingList(); - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); - } - refusal = array; + refusal = new ChangeTrackingList(); continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(ChatTokenLogProbabilityDetails.DeserializeChatTokenLogProbabilityDetails(item, options)); } + refusal = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateChatCompletionStreamResponseChoiceLogprobs(content, refusal, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateChatCompletionStreamResponseChoiceLogprobs(content, refusal, serializedAdditionalRawData); + } - InternalCreateChatCompletionStreamResponseChoiceLogprobs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateChatCompletionStreamResponseChoiceLogprobs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateChatCompletionStreamResponseChoiceLogprobs FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseChoiceLogprobs)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateChatCompletionStreamResponseChoiceLogprobs FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateChatCompletionStreamResponseChoiceLogprobs(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.cs index 9b927d50..d29e5d2e 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseChoiceLogprobs.cs @@ -6,29 +6,28 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionStreamResponseChoiceLogprobs { - internal partial class InternalCreateChatCompletionStreamResponseChoiceLogprobs + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateChatCompletionStreamResponseChoiceLogprobs(IEnumerable content, IEnumerable refusal) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateChatCompletionStreamResponseChoiceLogprobs(IEnumerable content, IEnumerable refusal) - { - Content = content?.ToList(); - Refusal = refusal?.ToList(); - } - - internal InternalCreateChatCompletionStreamResponseChoiceLogprobs(IReadOnlyList content, IReadOnlyList refusal, IDictionary serializedAdditionalRawData) - { - Content = content; - Refusal = refusal; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Content = content?.ToList(); + Refusal = refusal?.ToList(); + } - internal InternalCreateChatCompletionStreamResponseChoiceLogprobs() - { - } + internal InternalCreateChatCompletionStreamResponseChoiceLogprobs(IReadOnlyList content, IReadOnlyList refusal, IDictionary serializedAdditionalRawData) + { + Content = content; + Refusal = refusal; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public IReadOnlyList Content { get; } - public IReadOnlyList Refusal { get; } + internal InternalCreateChatCompletionStreamResponseChoiceLogprobs() + { } -} + + public IReadOnlyList Content { get; } + public IReadOnlyList Refusal { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseObject.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseObject.cs index 65aca720..3c1b2f74 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseObject.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionStreamResponseObject : IEquatable { - internal readonly partial struct InternalCreateChatCompletionStreamResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateChatCompletionStreamResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateChatCompletionStreamResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ChatCompletionChunkValue = "chat.completion.chunk"; + private const string ChatCompletionChunkValue = "chat.completion.chunk"; - public static InternalCreateChatCompletionStreamResponseObject ChatCompletionChunk { get; } = new InternalCreateChatCompletionStreamResponseObject(ChatCompletionChunkValue); - public static bool operator ==(InternalCreateChatCompletionStreamResponseObject left, InternalCreateChatCompletionStreamResponseObject right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionStreamResponseObject left, InternalCreateChatCompletionStreamResponseObject right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionStreamResponseObject(string value) => new InternalCreateChatCompletionStreamResponseObject(value); + public static InternalCreateChatCompletionStreamResponseObject ChatCompletionChunk { get; } = new InternalCreateChatCompletionStreamResponseObject(ChatCompletionChunkValue); + public static bool operator ==(InternalCreateChatCompletionStreamResponseObject left, InternalCreateChatCompletionStreamResponseObject right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionStreamResponseObject left, InternalCreateChatCompletionStreamResponseObject right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionStreamResponseObject(string value) => new InternalCreateChatCompletionStreamResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionStreamResponseObject other && Equals(other); - public bool Equals(InternalCreateChatCompletionStreamResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionStreamResponseObject other && Equals(other); + public bool Equals(InternalCreateChatCompletionStreamResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseServiceTier.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseServiceTier.cs index 0f2eb132..2ae6b709 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseServiceTier.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseServiceTier.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal readonly partial struct InternalCreateChatCompletionStreamResponseServiceTier : IEquatable { - internal readonly partial struct InternalCreateChatCompletionStreamResponseServiceTier : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateChatCompletionStreamResponseServiceTier(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateChatCompletionStreamResponseServiceTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ScaleValue = "scale"; - private const string DefaultValue = "default"; + private const string ScaleValue = "scale"; + private const string DefaultValue = "default"; - public static InternalCreateChatCompletionStreamResponseServiceTier Scale { get; } = new InternalCreateChatCompletionStreamResponseServiceTier(ScaleValue); - public static InternalCreateChatCompletionStreamResponseServiceTier Default { get; } = new InternalCreateChatCompletionStreamResponseServiceTier(DefaultValue); - public static bool operator ==(InternalCreateChatCompletionStreamResponseServiceTier left, InternalCreateChatCompletionStreamResponseServiceTier right) => left.Equals(right); - public static bool operator !=(InternalCreateChatCompletionStreamResponseServiceTier left, InternalCreateChatCompletionStreamResponseServiceTier right) => !left.Equals(right); - public static implicit operator InternalCreateChatCompletionStreamResponseServiceTier(string value) => new InternalCreateChatCompletionStreamResponseServiceTier(value); + public static InternalCreateChatCompletionStreamResponseServiceTier Scale { get; } = new InternalCreateChatCompletionStreamResponseServiceTier(ScaleValue); + public static InternalCreateChatCompletionStreamResponseServiceTier Default { get; } = new InternalCreateChatCompletionStreamResponseServiceTier(DefaultValue); + public static bool operator ==(InternalCreateChatCompletionStreamResponseServiceTier left, InternalCreateChatCompletionStreamResponseServiceTier right) => left.Equals(right); + public static bool operator !=(InternalCreateChatCompletionStreamResponseServiceTier left, InternalCreateChatCompletionStreamResponseServiceTier right) => !left.Equals(right); + public static implicit operator InternalCreateChatCompletionStreamResponseServiceTier(string value) => new InternalCreateChatCompletionStreamResponseServiceTier(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateChatCompletionStreamResponseServiceTier other && Equals(other); - public bool Equals(InternalCreateChatCompletionStreamResponseServiceTier other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateChatCompletionStreamResponseServiceTier other && Equals(other); + public bool Equals(InternalCreateChatCompletionStreamResponseServiceTier other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs index 300a01f0..01e7a4cc 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionStreamResponseUsage : IJsonModel { - internal partial class InternalCreateChatCompletionStreamResponseUsage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) - { - writer.WritePropertyName("completion_tokens"u8); - writer.WriteNumberValue(CompletionTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) - { - writer.WritePropertyName("prompt_tokens"u8); - writer.WriteNumberValue(PromptTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) - { - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) + { + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(CompletionTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) + { + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(PromptTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) + { + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateChatCompletionStreamResponseUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateChatCompletionStreamResponseUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateChatCompletionStreamResponseUsage(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support reading '{format}' format."); } - internal static InternalCreateChatCompletionStreamResponseUsage DeserializeInternalCreateChatCompletionStreamResponseUsage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateChatCompletionStreamResponseUsage(document.RootElement, options); + } + + internal static InternalCreateChatCompletionStreamResponseUsage DeserializeInternalCreateChatCompletionStreamResponseUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int completionTokens = default; + int promptTokens = default; + int totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) { - return null; + completionTokens = property.Value.GetInt32(); + continue; } - int completionTokens = default; - int promptTokens = default; - int totalTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("prompt_tokens"u8)) { - if (property.NameEquals("completion_tokens"u8)) - { - completionTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("prompt_tokens"u8)) - { - promptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total_tokens"u8)) - { - totalTokens = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + promptTokens = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateChatCompletionStreamResponseUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("total_tokens"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support writing '{options.Format}' format."); + totalTokens = property.Value.GetInt32(); + continue; } - } - - InternalCreateChatCompletionStreamResponseUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateChatCompletionStreamResponseUsage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateChatCompletionStreamResponseUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateChatCompletionStreamResponseUsage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateChatCompletionStreamResponseUsage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support writing '{options.Format}' format."); } + } + + InternalCreateChatCompletionStreamResponseUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateChatCompletionStreamResponseUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateChatCompletionStreamResponseUsage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateChatCompletionStreamResponseUsage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateChatCompletionStreamResponseUsage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs index 922ce4ca..b824cd45 100644 --- a/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs +++ b/src/Generated/Models/InternalCreateChatCompletionStreamResponseUsage.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalCreateChatCompletionStreamResponseUsage { - internal partial class InternalCreateChatCompletionStreamResponseUsage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, int promptTokens, int totalTokens) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, int promptTokens, int totalTokens) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - } - - internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, int promptTokens, int totalTokens, IDictionary serializedAdditionalRawData) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + } - internal InternalCreateChatCompletionStreamResponseUsage() - { - } + internal InternalCreateChatCompletionStreamResponseUsage(int completionTokens, int promptTokens, int totalTokens, IDictionary serializedAdditionalRawData) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int CompletionTokens { get; } - public int PromptTokens { get; } - public int TotalTokens { get; } + internal InternalCreateChatCompletionStreamResponseUsage() + { } -} + + public int CompletionTokens { get; } + public int PromptTokens { get; } + public int TotalTokens { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionRequest.Serialization.cs b/src/Generated/Models/InternalCreateCompletionRequest.Serialization.cs index 6658d5c4..4cc27921 100644 --- a/src/Generated/Models/InternalCreateCompletionRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateCompletionRequest.Serialization.cs @@ -9,548 +9,547 @@ using System.Text.Json; using OpenAI.Chat; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionRequest : IJsonModel { - internal partial class InternalCreateCompletionRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("model") != true) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("prompt") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("prompt") != true) + { + if (Prompt != null) { - if (Prompt != null) - { - writer.WritePropertyName("prompt"u8); + writer.WritePropertyName("prompt"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Prompt); #else - using (JsonDocument document = JsonDocument.Parse(Prompt)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else + using (JsonDocument document = JsonDocument.Parse(Prompt)) { - writer.WriteNull("prompt"); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - if (SerializedAdditionalRawData?.ContainsKey("best_of") != true && Optional.IsDefined(BestOf)) + else { - if (BestOf != null) - { - writer.WritePropertyName("best_of"u8); - writer.WriteNumberValue(BestOf.Value); - } - else - { - writer.WriteNull("best_of"); - } + writer.WriteNull("prompt"); } - if (SerializedAdditionalRawData?.ContainsKey("echo") != true && Optional.IsDefined(Echo)) + } + if (SerializedAdditionalRawData?.ContainsKey("best_of") != true && Optional.IsDefined(BestOf)) + { + if (BestOf != null) { - if (Echo != null) - { - writer.WritePropertyName("echo"u8); - writer.WriteBooleanValue(Echo.Value); - } - else - { - writer.WriteNull("echo"); - } + writer.WritePropertyName("best_of"u8); + writer.WriteNumberValue(BestOf.Value); } - if (SerializedAdditionalRawData?.ContainsKey("frequency_penalty") != true && Optional.IsDefined(FrequencyPenalty)) + else { - if (FrequencyPenalty != null) - { - writer.WritePropertyName("frequency_penalty"u8); - writer.WriteNumberValue(FrequencyPenalty.Value); - } - else - { - writer.WriteNull("frequency_penalty"); - } + writer.WriteNull("best_of"); } - if (SerializedAdditionalRawData?.ContainsKey("logit_bias") != true && Optional.IsCollectionDefined(LogitBias)) + } + if (SerializedAdditionalRawData?.ContainsKey("echo") != true && Optional.IsDefined(Echo)) + { + if (Echo != null) { - if (LogitBias != null) - { - writer.WritePropertyName("logit_bias"u8); - writer.WriteStartObject(); - foreach (var item in LogitBias) - { - writer.WritePropertyName(item.Key); - writer.WriteNumberValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("logit_bias"); - } + writer.WritePropertyName("echo"u8); + writer.WriteBooleanValue(Echo.Value); } - if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true && Optional.IsDefined(Logprobs)) + else { - if (Logprobs != null) - { - writer.WritePropertyName("logprobs"u8); - writer.WriteNumberValue(Logprobs.Value); - } - else - { - writer.WriteNull("logprobs"); - } + writer.WriteNull("echo"); } - if (SerializedAdditionalRawData?.ContainsKey("max_tokens") != true && Optional.IsDefined(MaxTokens)) + } + if (SerializedAdditionalRawData?.ContainsKey("frequency_penalty") != true && Optional.IsDefined(FrequencyPenalty)) + { + if (FrequencyPenalty != null) { - if (MaxTokens != null) - { - writer.WritePropertyName("max_tokens"u8); - writer.WriteNumberValue(MaxTokens.Value); - } - else - { - writer.WriteNull("max_tokens"); - } + writer.WritePropertyName("frequency_penalty"u8); + writer.WriteNumberValue(FrequencyPenalty.Value); } - if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + else { - if (N != null) - { - writer.WritePropertyName("n"u8); - writer.WriteNumberValue(N.Value); - } - else - { - writer.WriteNull("n"); - } + writer.WriteNull("frequency_penalty"); } - if (SerializedAdditionalRawData?.ContainsKey("presence_penalty") != true && Optional.IsDefined(PresencePenalty)) + } + if (SerializedAdditionalRawData?.ContainsKey("logit_bias") != true && Optional.IsCollectionDefined(LogitBias)) + { + if (LogitBias != null) { - if (PresencePenalty != null) - { - writer.WritePropertyName("presence_penalty"u8); - writer.WriteNumberValue(PresencePenalty.Value); - } - else + writer.WritePropertyName("logit_bias"u8); + writer.WriteStartObject(); + foreach (var item in LogitBias) { - writer.WriteNull("presence_penalty"); + writer.WritePropertyName(item.Key); + writer.WriteNumberValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("seed") != true && Optional.IsDefined(Seed)) + else { - if (Seed != null) - { - writer.WritePropertyName("seed"u8); - writer.WriteNumberValue(Seed.Value); - } - else - { - writer.WriteNull("seed"); - } + writer.WriteNull("logit_bias"); } - if (SerializedAdditionalRawData?.ContainsKey("stop") != true && Optional.IsDefined(Stop)) + } + if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true && Optional.IsDefined(Logprobs)) + { + if (Logprobs != null) { - if (Stop != null) - { - writer.WritePropertyName("stop"u8); + writer.WritePropertyName("logprobs"u8); + writer.WriteNumberValue(Logprobs.Value); + } + else + { + writer.WriteNull("logprobs"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("max_tokens") != true && Optional.IsDefined(MaxTokens)) + { + if (MaxTokens != null) + { + writer.WritePropertyName("max_tokens"u8); + writer.WriteNumberValue(MaxTokens.Value); + } + else + { + writer.WriteNull("max_tokens"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("n") != true && Optional.IsDefined(N)) + { + if (N != null) + { + writer.WritePropertyName("n"u8); + writer.WriteNumberValue(N.Value); + } + else + { + writer.WriteNull("n"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("presence_penalty") != true && Optional.IsDefined(PresencePenalty)) + { + if (PresencePenalty != null) + { + writer.WritePropertyName("presence_penalty"u8); + writer.WriteNumberValue(PresencePenalty.Value); + } + else + { + writer.WriteNull("presence_penalty"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("seed") != true && Optional.IsDefined(Seed)) + { + if (Seed != null) + { + writer.WritePropertyName("seed"u8); + writer.WriteNumberValue(Seed.Value); + } + else + { + writer.WriteNull("seed"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("stop") != true && Optional.IsDefined(Stop)) + { + if (Stop != null) + { + writer.WritePropertyName("stop"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Stop); #else - using (JsonDocument document = JsonDocument.Parse(Stop)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - else + using (JsonDocument document = JsonDocument.Parse(Stop)) { - writer.WriteNull("stop"); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + else { - if (Stream != null) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - else - { - writer.WriteNull("stream"); - } + writer.WriteNull("stop"); } - if (SerializedAdditionalRawData?.ContainsKey("stream_options") != true && Optional.IsDefined(StreamOptions)) + } + if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + { + if (Stream != null) { - if (StreamOptions != null) - { - writer.WritePropertyName("stream_options"u8); - writer.WriteObjectValue(StreamOptions, options); - } - else - { - writer.WriteNull("stream_options"); - } + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); } - if (SerializedAdditionalRawData?.ContainsKey("suffix") != true && Optional.IsDefined(Suffix)) + else { - if (Suffix != null) - { - writer.WritePropertyName("suffix"u8); - writer.WriteStringValue(Suffix); - } - else - { - writer.WriteNull("suffix"); - } + writer.WriteNull("stream"); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + } + if (SerializedAdditionalRawData?.ContainsKey("stream_options") != true && Optional.IsDefined(StreamOptions)) + { + if (StreamOptions != null) { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } + writer.WritePropertyName("stream_options"u8); + writer.WriteObjectValue(StreamOptions, options); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(TopP)) + else { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } + writer.WriteNull("stream_options"); } - if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(User)) + } + if (SerializedAdditionalRawData?.ContainsKey("suffix") != true && Optional.IsDefined(Suffix)) + { + if (Suffix != null) { - writer.WritePropertyName("user"u8); - writer.WriteStringValue(User); + writer.WritePropertyName("suffix"u8); + writer.WriteStringValue(Suffix); } - if (SerializedAdditionalRawData != null) + else + { + writer.WriteNull("suffix"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("user") != true && Optional.IsDefined(User)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(User); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateCompletionRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateCompletionRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateCompletionRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support reading '{format}' format."); } - internal static InternalCreateCompletionRequest DeserializeInternalCreateCompletionRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateCompletionRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalCreateCompletionRequestModel model = default; - BinaryData prompt = default; - int? bestOf = default; - bool? echo = default; - float? frequencyPenalty = default; - IDictionary logitBias = default; - int? logprobs = default; - int? maxTokens = default; - int? n = default; - float? presencePenalty = default; - long? seed = default; - BinaryData stop = default; - bool? stream = default; - InternalChatCompletionStreamOptions streamOptions = default; - string suffix = default; - float? temperature = default; - float? topP = default; - string user = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("model"u8)) - { - model = new InternalCreateCompletionRequestModel(property.Value.GetString()); - continue; - } - if (property.NameEquals("prompt"u8)) + internal static InternalCreateCompletionRequest DeserializeInternalCreateCompletionRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateCompletionRequestModel model = default; + BinaryData prompt = default; + int? bestOf = default; + bool? echo = default; + float? frequencyPenalty = default; + IDictionary logitBias = default; + int? logprobs = default; + int? maxTokens = default; + int? n = default; + float? presencePenalty = default; + long? seed = default; + BinaryData stop = default; + bool? stream = default; + InternalChatCompletionStreamOptions streamOptions = default; + string suffix = default; + float? temperature = default; + float? topP = default; + string user = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) + { + model = new InternalCreateCompletionRequestModel(property.Value.GetString()); + continue; + } + if (property.NameEquals("prompt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - prompt = null; - continue; - } - prompt = BinaryData.FromString(property.Value.GetRawText()); + prompt = null; continue; } - if (property.NameEquals("best_of"u8)) + prompt = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("best_of"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - bestOf = null; - continue; - } - bestOf = property.Value.GetInt32(); + bestOf = null; continue; } - if (property.NameEquals("echo"u8)) + bestOf = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("echo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - echo = null; - continue; - } - echo = property.Value.GetBoolean(); + echo = null; continue; } - if (property.NameEquals("frequency_penalty"u8)) + echo = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("frequency_penalty"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - frequencyPenalty = null; - continue; - } - frequencyPenalty = property.Value.GetSingle(); + frequencyPenalty = null; continue; } - if (property.NameEquals("logit_bias"u8)) + frequencyPenalty = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("logit_bias"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetInt32()); - } - logitBias = dictionary; continue; } - if (property.NameEquals("logprobs"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - logprobs = null; - continue; - } - logprobs = property.Value.GetInt32(); - continue; + dictionary.Add(property0.Name, property0.Value.GetInt32()); } - if (property.NameEquals("max_tokens"u8)) + logitBias = dictionary; + continue; + } + if (property.NameEquals("logprobs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxTokens = null; - continue; - } - maxTokens = property.Value.GetInt32(); + logprobs = null; continue; } - if (property.NameEquals("n"u8)) + logprobs = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - n = null; - continue; - } - n = property.Value.GetInt32(); + maxTokens = null; continue; } - if (property.NameEquals("presence_penalty"u8)) + maxTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("n"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - presencePenalty = null; - continue; - } - presencePenalty = property.Value.GetSingle(); + n = null; continue; } - if (property.NameEquals("seed"u8)) + n = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("presence_penalty"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - seed = null; - continue; - } - seed = property.Value.GetInt64(); + presencePenalty = null; continue; } - if (property.NameEquals("stop"u8)) + presencePenalty = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("seed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - stop = null; - continue; - } - stop = BinaryData.FromString(property.Value.GetRawText()); + seed = null; continue; } - if (property.NameEquals("stream"u8)) + seed = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("stop"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - stream = null; - continue; - } - stream = property.Value.GetBoolean(); + stop = null; continue; } - if (property.NameEquals("stream_options"u8)) + stop = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - streamOptions = null; - continue; - } - streamOptions = InternalChatCompletionStreamOptions.DeserializeInternalChatCompletionStreamOptions(property.Value, options); + stream = null; continue; } - if (property.NameEquals("suffix"u8)) + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("stream_options"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - suffix = null; - continue; - } - suffix = property.Value.GetString(); + streamOptions = null; continue; } - if (property.NameEquals("temperature"u8)) + streamOptions = InternalChatCompletionStreamOptions.DeserializeInternalChatCompletionStreamOptions(property.Value, options); + continue; + } + if (property.NameEquals("suffix"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); + suffix = null; continue; } - if (property.NameEquals("top_p"u8)) + suffix = property.Value.GetString(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); + temperature = null; continue; } - if (property.NameEquals("user"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - user = property.Value.GetString(); + topP = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + topP = property.Value.GetSingle(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateCompletionRequest( - model, - prompt, - bestOf, - echo, - frequencyPenalty, - logitBias ?? new ChangeTrackingDictionary(), - logprobs, - maxTokens, - n, - presencePenalty, - seed, - stop, - stream, - streamOptions, - suffix, - temperature, - topP, - user, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("user"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support writing '{options.Format}' format."); + user = property.Value.GetString(); + continue; } - } - - InternalCreateCompletionRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateCompletionRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateCompletionRequest( + model, + prompt, + bestOf, + echo, + frequencyPenalty, + logitBias ?? new ChangeTrackingDictionary(), + logprobs, + maxTokens, + n, + presencePenalty, + seed, + stop, + stream, + streamOptions, + suffix, + temperature, + topP, + user, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateCompletionRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateCompletionRequest(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support writing '{options.Format}' format."); } + } + + InternalCreateCompletionRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateCompletionRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionRequest)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateCompletionRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateCompletionRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionRequest.cs b/src/Generated/Models/InternalCreateCompletionRequest.cs index 25e584d3..31972e6b 100644 --- a/src/Generated/Models/InternalCreateCompletionRequest.cs +++ b/src/Generated/Models/InternalCreateCompletionRequest.cs @@ -6,62 +6,61 @@ using System.Collections.Generic; using OpenAI.Chat; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionRequest { - internal partial class InternalCreateCompletionRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateCompletionRequest(InternalCreateCompletionRequestModel model, BinaryData prompt) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateCompletionRequest(InternalCreateCompletionRequestModel model, BinaryData prompt) - { - Model = model; - Prompt = prompt; - LogitBias = new ChangeTrackingDictionary(); - } - - internal InternalCreateCompletionRequest(InternalCreateCompletionRequestModel model, BinaryData prompt, int? bestOf, bool? echo, float? frequencyPenalty, IDictionary logitBias, int? logprobs, int? maxTokens, int? n, float? presencePenalty, long? seed, BinaryData stop, bool? stream, InternalChatCompletionStreamOptions streamOptions, string suffix, float? temperature, float? topP, string user, IDictionary serializedAdditionalRawData) - { - Model = model; - Prompt = prompt; - BestOf = bestOf; - Echo = echo; - FrequencyPenalty = frequencyPenalty; - LogitBias = logitBias; - Logprobs = logprobs; - MaxTokens = maxTokens; - N = n; - PresencePenalty = presencePenalty; - Seed = seed; - Stop = stop; - Stream = stream; - StreamOptions = streamOptions; - Suffix = suffix; - Temperature = temperature; - TopP = topP; - User = user; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Model = model; + Prompt = prompt; + LogitBias = new ChangeTrackingDictionary(); + } - internal InternalCreateCompletionRequest() - { - } + internal InternalCreateCompletionRequest(InternalCreateCompletionRequestModel model, BinaryData prompt, int? bestOf, bool? echo, float? frequencyPenalty, IDictionary logitBias, int? logprobs, int? maxTokens, int? n, float? presencePenalty, long? seed, BinaryData stop, bool? stream, InternalChatCompletionStreamOptions streamOptions, string suffix, float? temperature, float? topP, string user, IDictionary serializedAdditionalRawData) + { + Model = model; + Prompt = prompt; + BestOf = bestOf; + Echo = echo; + FrequencyPenalty = frequencyPenalty; + LogitBias = logitBias; + Logprobs = logprobs; + MaxTokens = maxTokens; + N = n; + PresencePenalty = presencePenalty; + Seed = seed; + Stop = stop; + Stream = stream; + StreamOptions = streamOptions; + Suffix = suffix; + Temperature = temperature; + TopP = topP; + User = user; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public InternalCreateCompletionRequestModel Model { get; } - public BinaryData Prompt { get; } - public int? BestOf { get; set; } - public bool? Echo { get; set; } - public float? FrequencyPenalty { get; set; } - public IDictionary LogitBias { get; set; } - public int? Logprobs { get; set; } - public int? MaxTokens { get; set; } - public int? N { get; set; } - public float? PresencePenalty { get; set; } - public long? Seed { get; set; } - public BinaryData Stop { get; set; } - public bool? Stream { get; set; } - public InternalChatCompletionStreamOptions StreamOptions { get; set; } - public string Suffix { get; set; } - public float? Temperature { get; set; } - public float? TopP { get; set; } - public string User { get; set; } + internal InternalCreateCompletionRequest() + { } -} + + public InternalCreateCompletionRequestModel Model { get; } + public BinaryData Prompt { get; } + public int? BestOf { get; set; } + public bool? Echo { get; set; } + public float? FrequencyPenalty { get; set; } + public IDictionary LogitBias { get; set; } + public int? Logprobs { get; set; } + public int? MaxTokens { get; set; } + public int? N { get; set; } + public float? PresencePenalty { get; set; } + public long? Seed { get; set; } + public BinaryData Stop { get; set; } + public bool? Stream { get; set; } + public InternalChatCompletionStreamOptions StreamOptions { get; set; } + public string Suffix { get; set; } + public float? Temperature { get; set; } + public float? TopP { get; set; } + public string User { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionRequestModel.cs b/src/Generated/Models/InternalCreateCompletionRequestModel.cs index 46b5e9d0..4f541036 100644 --- a/src/Generated/Models/InternalCreateCompletionRequestModel.cs +++ b/src/Generated/Models/InternalCreateCompletionRequestModel.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal readonly partial struct InternalCreateCompletionRequestModel : IEquatable { - internal readonly partial struct InternalCreateCompletionRequestModel : IEquatable + private readonly string _value; + + public InternalCreateCompletionRequestModel(string value) { - private readonly string _value; - - public InternalCreateCompletionRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string Gpt35TurboInstructValue = "gpt-3.5-turbo-instruct"; - private const string Davinci002Value = "davinci-002"; - private const string Babbage002Value = "babbage-002"; - - public static InternalCreateCompletionRequestModel Gpt35TurboInstruct { get; } = new InternalCreateCompletionRequestModel(Gpt35TurboInstructValue); - public static InternalCreateCompletionRequestModel Davinci002 { get; } = new InternalCreateCompletionRequestModel(Davinci002Value); - public static InternalCreateCompletionRequestModel Babbage002 { get; } = new InternalCreateCompletionRequestModel(Babbage002Value); - public static bool operator ==(InternalCreateCompletionRequestModel left, InternalCreateCompletionRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateCompletionRequestModel left, InternalCreateCompletionRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateCompletionRequestModel(string value) => new InternalCreateCompletionRequestModel(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateCompletionRequestModel other && Equals(other); - public bool Equals(InternalCreateCompletionRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string Gpt35TurboInstructValue = "gpt-3.5-turbo-instruct"; + private const string Davinci002Value = "davinci-002"; + private const string Babbage002Value = "babbage-002"; + + public static InternalCreateCompletionRequestModel Gpt35TurboInstruct { get; } = new InternalCreateCompletionRequestModel(Gpt35TurboInstructValue); + public static InternalCreateCompletionRequestModel Davinci002 { get; } = new InternalCreateCompletionRequestModel(Davinci002Value); + public static InternalCreateCompletionRequestModel Babbage002 { get; } = new InternalCreateCompletionRequestModel(Babbage002Value); + public static bool operator ==(InternalCreateCompletionRequestModel left, InternalCreateCompletionRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateCompletionRequestModel left, InternalCreateCompletionRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateCompletionRequestModel(string value) => new InternalCreateCompletionRequestModel(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateCompletionRequestModel other && Equals(other); + public bool Equals(InternalCreateCompletionRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponse.Serialization.cs b/src/Generated/Models/InternalCreateCompletionResponse.Serialization.cs index 7f641dc9..36afc250 100644 --- a/src/Generated/Models/InternalCreateCompletionResponse.Serialization.cs +++ b/src/Generated/Models/InternalCreateCompletionResponse.Serialization.cs @@ -9,214 +9,213 @@ using System.Text.Json; using OpenAI.Chat; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionResponse : IJsonModel { - internal partial class InternalCreateCompletionResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + { + writer.WritePropertyName("choices"u8); + writer.WriteStartArray(); + foreach (var item in Choices) { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("created") != true) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(Created, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) + { + writer.WritePropertyName("system_fingerprint"u8); + writer.WriteStringValue(SystemFingerprint); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("choices"u8); - writer.WriteStartArray(); - foreach (var item in Choices) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("created") != true) - { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(Created, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); - } - if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) - { - writer.WritePropertyName("system_fingerprint"u8); - writer.WriteStringValue(SystemFingerprint); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) - { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateCompletionResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateCompletionResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateCompletionResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support reading '{format}' format."); } - internal static InternalCreateCompletionResponse DeserializeInternalCreateCompletionResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateCompletionResponse(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalCreateCompletionResponse DeserializeInternalCreateCompletionResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IReadOnlyList choices = default; + DateTimeOffset created = default; + string model = default; + string systemFingerprint = default; + InternalCreateCompletionResponseObject @object = default; + ChatTokenUsage usage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - IReadOnlyList choices = default; - DateTimeOffset created = default; - string model = default; - string systemFingerprint = default; - InternalCreateCompletionResponseObject @object = default; - ChatTokenUsage usage = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("choices"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("choices"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalCreateCompletionResponseChoice.DeserializeInternalCreateCompletionResponseChoice(item, options)); - } - choices = array; - continue; + array.Add(InternalCreateCompletionResponseChoice.DeserializeInternalCreateCompletionResponseChoice(item, options)); } - if (property.NameEquals("created"u8)) - { - created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("system_fingerprint"u8)) - { - systemFingerprint = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalCreateCompletionResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("usage"u8)) + choices = array; + continue; + } + if (property.NameEquals("created"u8)) + { + created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("system_fingerprint"u8)) + { + systemFingerprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalCreateCompletionResponseObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateCompletionResponse( - id, - choices, - created, - model, - systemFingerprint, - @object, - usage, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateCompletionResponse( + id, + choices, + created, + model, + systemFingerprint, + @object, + usage, + serializedAdditionalRawData); + } - InternalCreateCompletionResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateCompletionResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateCompletionResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateCompletionResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateCompletionResponse(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateCompletionResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionResponse)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateCompletionResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateCompletionResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponse.cs b/src/Generated/Models/InternalCreateCompletionResponse.cs index b7dd5c2a..9644234b 100644 --- a/src/Generated/Models/InternalCreateCompletionResponse.cs +++ b/src/Generated/Models/InternalCreateCompletionResponse.cs @@ -7,46 +7,45 @@ using System.Linq; using OpenAI.Chat; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionResponse { - internal partial class InternalCreateCompletionResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateCompletionResponse(string id, IEnumerable choices, DateTimeOffset created, string model) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateCompletionResponse(string id, IEnumerable choices, DateTimeOffset created, string model) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(choices, nameof(choices)); - Argument.AssertNotNull(model, nameof(model)); - - Id = id; - Choices = choices.ToList(); - Created = created; - Model = model; - } - - internal InternalCreateCompletionResponse(string id, IReadOnlyList choices, DateTimeOffset created, string model, string systemFingerprint, InternalCreateCompletionResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) - { - Id = id; - Choices = choices; - Created = created; - Model = model; - SystemFingerprint = systemFingerprint; - Object = @object; - Usage = usage; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateCompletionResponse() - { - } - - public string Id { get; } - public IReadOnlyList Choices { get; } - public DateTimeOffset Created { get; } - public string Model { get; } - public string SystemFingerprint { get; } - public InternalCreateCompletionResponseObject Object { get; } = InternalCreateCompletionResponseObject.TextCompletion; - - public ChatTokenUsage Usage { get; } + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(choices, nameof(choices)); + Argument.AssertNotNull(model, nameof(model)); + + Id = id; + Choices = choices.ToList(); + Created = created; + Model = model; } -} + + internal InternalCreateCompletionResponse(string id, IReadOnlyList choices, DateTimeOffset created, string model, string systemFingerprint, InternalCreateCompletionResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) + { + Id = id; + Choices = choices; + Created = created; + Model = model; + SystemFingerprint = systemFingerprint; + Object = @object; + Usage = usage; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalCreateCompletionResponse() + { + } + + public string Id { get; } + public IReadOnlyList Choices { get; } + public DateTimeOffset Created { get; } + public string Model { get; } + public string SystemFingerprint { get; } + public InternalCreateCompletionResponseObject Object { get; } = InternalCreateCompletionResponseObject.TextCompletion; + + public ChatTokenUsage Usage { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponseChoice.Serialization.cs b/src/Generated/Models/InternalCreateCompletionResponseChoice.Serialization.cs index b4915100..b589d6e4 100644 --- a/src/Generated/Models/InternalCreateCompletionResponseChoice.Serialization.cs +++ b/src/Generated/Models/InternalCreateCompletionResponseChoice.Serialization.cs @@ -8,171 +8,170 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionResponseChoice : IJsonModel { - internal partial class InternalCreateCompletionResponseChoice : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("finish_reason") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("finish_reason") != true) + { + writer.WritePropertyName("finish_reason"u8); + writer.WriteStringValue(FinishReason.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true) + { + if (Logprobs != null) { - writer.WritePropertyName("finish_reason"u8); - writer.WriteStringValue(FinishReason.ToString()); + writer.WritePropertyName("logprobs"u8); + writer.WriteObjectValue(Logprobs, options); } - if (SerializedAdditionalRawData?.ContainsKey("index") != true) + else { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); + writer.WriteNull("logprobs"); } - if (SerializedAdditionalRawData?.ContainsKey("logprobs") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Logprobs != null) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WritePropertyName("logprobs"u8); - writer.WriteObjectValue(Logprobs, options); - } - else - { - writer.WriteNull("logprobs"); + continue; } - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateCompletionResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateCompletionResponseChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateCompletionResponseChoice(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support reading '{format}' format."); } - internal static InternalCreateCompletionResponseChoice DeserializeInternalCreateCompletionResponseChoice(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateCompletionResponseChoice(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalCreateCompletionResponseChoice DeserializeInternalCreateCompletionResponseChoice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateCompletionResponseChoiceFinishReason finishReason = default; + int index = default; + InternalCreateCompletionResponseChoiceLogprobs logprobs = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("finish_reason"u8)) { - return null; + finishReason = new InternalCreateCompletionResponseChoiceFinishReason(property.Value.GetString()); + continue; } - InternalCreateCompletionResponseChoiceFinishReason finishReason = default; - int index = default; - InternalCreateCompletionResponseChoiceLogprobs logprobs = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("index"u8)) { - if (property.NameEquals("finish_reason"u8)) - { - finishReason = new InternalCreateCompletionResponseChoiceFinishReason(property.Value.GetString()); - continue; - } - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("logprobs"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - logprobs = null; - continue; - } - logprobs = InternalCreateCompletionResponseChoiceLogprobs.DeserializeInternalCreateCompletionResponseChoiceLogprobs(property.Value, options); - continue; - } - if (property.NameEquals("text"u8)) + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("logprobs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - text = property.Value.GetString(); + logprobs = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + logprobs = InternalCreateCompletionResponseChoiceLogprobs.DeserializeInternalCreateCompletionResponseChoiceLogprobs(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateCompletionResponseChoice(finishReason, index, logprobs, text, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("text"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support writing '{options.Format}' format."); + text = property.Value.GetString(); + continue; } - } - - InternalCreateCompletionResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateCompletionResponseChoice(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateCompletionResponseChoice(finishReason, index, logprobs, text, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateCompletionResponseChoice FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateCompletionResponseChoice(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support writing '{options.Format}' format."); } + } + + InternalCreateCompletionResponseChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateCompletionResponseChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoice)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateCompletionResponseChoice FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateCompletionResponseChoice(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponseChoice.cs b/src/Generated/Models/InternalCreateCompletionResponseChoice.cs index 5aa7f0cc..adfea577 100644 --- a/src/Generated/Models/InternalCreateCompletionResponseChoice.cs +++ b/src/Generated/Models/InternalCreateCompletionResponseChoice.cs @@ -5,37 +5,36 @@ using System; using System.Collections.Generic; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionResponseChoice { - internal partial class InternalCreateCompletionResponseChoice + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateCompletionResponseChoice(InternalCreateCompletionResponseChoiceFinishReason finishReason, int index, InternalCreateCompletionResponseChoiceLogprobs logprobs, string text) + { + Argument.AssertNotNull(text, nameof(text)); + + FinishReason = finishReason; + Index = index; + Logprobs = logprobs; + Text = text; + } + + internal InternalCreateCompletionResponseChoice(InternalCreateCompletionResponseChoiceFinishReason finishReason, int index, InternalCreateCompletionResponseChoiceLogprobs logprobs, string text, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateCompletionResponseChoice(InternalCreateCompletionResponseChoiceFinishReason finishReason, int index, InternalCreateCompletionResponseChoiceLogprobs logprobs, string text) - { - Argument.AssertNotNull(text, nameof(text)); - - FinishReason = finishReason; - Index = index; - Logprobs = logprobs; - Text = text; - } - - internal InternalCreateCompletionResponseChoice(InternalCreateCompletionResponseChoiceFinishReason finishReason, int index, InternalCreateCompletionResponseChoiceLogprobs logprobs, string text, IDictionary serializedAdditionalRawData) - { - FinishReason = finishReason; - Index = index; - Logprobs = logprobs; - Text = text; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateCompletionResponseChoice() - { - } - - public InternalCreateCompletionResponseChoiceFinishReason FinishReason { get; } - public int Index { get; } - public InternalCreateCompletionResponseChoiceLogprobs Logprobs { get; } - public string Text { get; } + FinishReason = finishReason; + Index = index; + Logprobs = logprobs; + Text = text; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateCompletionResponseChoice() + { + } + + public InternalCreateCompletionResponseChoiceFinishReason FinishReason { get; } + public int Index { get; } + public InternalCreateCompletionResponseChoiceLogprobs Logprobs { get; } + public string Text { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponseChoiceFinishReason.cs b/src/Generated/Models/InternalCreateCompletionResponseChoiceFinishReason.cs index e10b1ef3..04cf61a1 100644 --- a/src/Generated/Models/InternalCreateCompletionResponseChoiceFinishReason.cs +++ b/src/Generated/Models/InternalCreateCompletionResponseChoiceFinishReason.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal readonly partial struct InternalCreateCompletionResponseChoiceFinishReason : IEquatable { - internal readonly partial struct InternalCreateCompletionResponseChoiceFinishReason : IEquatable + private readonly string _value; + + public InternalCreateCompletionResponseChoiceFinishReason(string value) { - private readonly string _value; - - public InternalCreateCompletionResponseChoiceFinishReason(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string StopValue = "stop"; - private const string LengthValue = "length"; - private const string ContentFilterValue = "content_filter"; - - public static InternalCreateCompletionResponseChoiceFinishReason Stop { get; } = new InternalCreateCompletionResponseChoiceFinishReason(StopValue); - public static InternalCreateCompletionResponseChoiceFinishReason Length { get; } = new InternalCreateCompletionResponseChoiceFinishReason(LengthValue); - public static InternalCreateCompletionResponseChoiceFinishReason ContentFilter { get; } = new InternalCreateCompletionResponseChoiceFinishReason(ContentFilterValue); - public static bool operator ==(InternalCreateCompletionResponseChoiceFinishReason left, InternalCreateCompletionResponseChoiceFinishReason right) => left.Equals(right); - public static bool operator !=(InternalCreateCompletionResponseChoiceFinishReason left, InternalCreateCompletionResponseChoiceFinishReason right) => !left.Equals(right); - public static implicit operator InternalCreateCompletionResponseChoiceFinishReason(string value) => new InternalCreateCompletionResponseChoiceFinishReason(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateCompletionResponseChoiceFinishReason other && Equals(other); - public bool Equals(InternalCreateCompletionResponseChoiceFinishReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string StopValue = "stop"; + private const string LengthValue = "length"; + private const string ContentFilterValue = "content_filter"; + + public static InternalCreateCompletionResponseChoiceFinishReason Stop { get; } = new InternalCreateCompletionResponseChoiceFinishReason(StopValue); + public static InternalCreateCompletionResponseChoiceFinishReason Length { get; } = new InternalCreateCompletionResponseChoiceFinishReason(LengthValue); + public static InternalCreateCompletionResponseChoiceFinishReason ContentFilter { get; } = new InternalCreateCompletionResponseChoiceFinishReason(ContentFilterValue); + public static bool operator ==(InternalCreateCompletionResponseChoiceFinishReason left, InternalCreateCompletionResponseChoiceFinishReason right) => left.Equals(right); + public static bool operator !=(InternalCreateCompletionResponseChoiceFinishReason left, InternalCreateCompletionResponseChoiceFinishReason right) => !left.Equals(right); + public static implicit operator InternalCreateCompletionResponseChoiceFinishReason(string value) => new InternalCreateCompletionResponseChoiceFinishReason(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateCompletionResponseChoiceFinishReason other && Equals(other); + public bool Equals(InternalCreateCompletionResponseChoiceFinishReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.Serialization.cs b/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.Serialization.cs index 9117d836..7b669b14 100644 --- a/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.Serialization.cs +++ b/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.Serialization.cs @@ -8,238 +8,237 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionResponseChoiceLogprobs : IJsonModel { - internal partial class InternalCreateCompletionResponseChoiceLogprobs : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("text_offset") != true && Optional.IsCollectionDefined(TextOffset)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("text_offset"u8); + writer.WriteStartArray(); + foreach (var item in TextOffset) { - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support writing '{format}' format."); + writer.WriteNumberValue(item); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("text_offset") != true && Optional.IsCollectionDefined(TextOffset)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("token_logprobs") != true && Optional.IsCollectionDefined(TokenLogprobs)) + { + writer.WritePropertyName("token_logprobs"u8); + writer.WriteStartArray(); + foreach (var item in TokenLogprobs) { - writer.WritePropertyName("text_offset"u8); - writer.WriteStartArray(); - foreach (var item in TextOffset) - { - writer.WriteNumberValue(item); - } - writer.WriteEndArray(); + writer.WriteNumberValue(item); } - if (SerializedAdditionalRawData?.ContainsKey("token_logprobs") != true && Optional.IsCollectionDefined(TokenLogprobs)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("tokens") != true && Optional.IsCollectionDefined(Tokens)) + { + writer.WritePropertyName("tokens"u8); + writer.WriteStartArray(); + foreach (var item in Tokens) { - writer.WritePropertyName("token_logprobs"u8); - writer.WriteStartArray(); - foreach (var item in TokenLogprobs) - { - writer.WriteNumberValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData?.ContainsKey("tokens") != true && Optional.IsCollectionDefined(Tokens)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("top_logprobs") != true && Optional.IsCollectionDefined(TopLogprobs)) + { + writer.WritePropertyName("top_logprobs"u8); + writer.WriteStartArray(); + foreach (var item in TopLogprobs) { - writer.WritePropertyName("tokens"u8); - writer.WriteStartArray(); - foreach (var item in Tokens) + if (item == null) { - writer.WriteStringValue(item); + writer.WriteNullValue(); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("top_logprobs") != true && Optional.IsCollectionDefined(TopLogprobs)) - { - writer.WritePropertyName("top_logprobs"u8); - writer.WriteStartArray(); - foreach (var item in TopLogprobs) + writer.WriteStartObject(); + foreach (var item0 in item) { - if (item == null) - { - writer.WriteNullValue(); - continue; - } - writer.WriteStartObject(); - foreach (var item0 in item) - { - writer.WritePropertyName(item0.Key); - writer.WriteNumberValue(item0.Value); - } - writer.WriteEndObject(); + writer.WritePropertyName(item0.Key); + writer.WriteNumberValue(item0.Value); } - writer.WriteEndArray(); + writer.WriteEndObject(); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateCompletionResponseChoiceLogprobs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateCompletionResponseChoiceLogprobs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateCompletionResponseChoiceLogprobs(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support reading '{format}' format."); } - internal static InternalCreateCompletionResponseChoiceLogprobs DeserializeInternalCreateCompletionResponseChoiceLogprobs(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateCompletionResponseChoiceLogprobs(document.RootElement, options); + } + + internal static InternalCreateCompletionResponseChoiceLogprobs DeserializeInternalCreateCompletionResponseChoiceLogprobs(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList textOffset = default; + IReadOnlyList tokenLogprobs = default; + IReadOnlyList tokens = default; + IReadOnlyList> topLogprobs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text_offset"u8)) { - return null; + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + textOffset = array; + continue; } - IReadOnlyList textOffset = default; - IReadOnlyList tokenLogprobs = default; - IReadOnlyList tokens = default; - IReadOnlyList> topLogprobs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("token_logprobs"u8)) { - if (property.NameEquals("text_offset"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetInt32()); - } - textOffset = array; continue; } - if (property.NameEquals("token_logprobs"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetSingle()); + } + tokenLogprobs = array; + continue; + } + if (property.NameEquals("tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetSingle()); - } - tokenLogprobs = array; continue; } - if (property.NameEquals("tokens"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + tokens = array; + continue; + } + if (property.NameEquals("top_logprobs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - tokens = array; continue; } - if (property.NameEquals("top_logprobs"u8)) + List> array = new List>(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (item.ValueKind == JsonValueKind.Null) { - continue; + array.Add(null); } - List> array = new List>(); - foreach (var item in property.Value.EnumerateArray()) + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else + Dictionary dictionary = new Dictionary(); + foreach (var property0 in item.EnumerateObject()) { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in item.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetSingle()); - } - array.Add(dictionary); + dictionary.Add(property0.Name, property0.Value.GetSingle()); } + array.Add(dictionary); } - topLogprobs = array; - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } + topLogprobs = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateCompletionResponseChoiceLogprobs(textOffset ?? new ChangeTrackingList(), tokenLogprobs ?? new ChangeTrackingList(), tokens ?? new ChangeTrackingList(), topLogprobs ?? new ChangeTrackingList>(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateCompletionResponseChoiceLogprobs(textOffset ?? new ChangeTrackingList(), tokenLogprobs ?? new ChangeTrackingList(), tokens ?? new ChangeTrackingList(), topLogprobs ?? new ChangeTrackingList>(), serializedAdditionalRawData); + } - InternalCreateCompletionResponseChoiceLogprobs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateCompletionResponseChoiceLogprobs(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateCompletionResponseChoiceLogprobs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateCompletionResponseChoiceLogprobs FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateCompletionResponseChoiceLogprobs(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateCompletionResponseChoiceLogprobs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateCompletionResponseChoiceLogprobs)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateCompletionResponseChoiceLogprobs FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateCompletionResponseChoiceLogprobs(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.cs b/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.cs index 6f5de82a..77e2cc74 100644 --- a/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.cs +++ b/src/Generated/Models/InternalCreateCompletionResponseChoiceLogprobs.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal partial class InternalCreateCompletionResponseChoiceLogprobs { - internal partial class InternalCreateCompletionResponseChoiceLogprobs + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateCompletionResponseChoiceLogprobs() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateCompletionResponseChoiceLogprobs() - { - TextOffset = new ChangeTrackingList(); - TokenLogprobs = new ChangeTrackingList(); - Tokens = new ChangeTrackingList(); - TopLogprobs = new ChangeTrackingList>(); - } - - internal InternalCreateCompletionResponseChoiceLogprobs(IReadOnlyList textOffset, IReadOnlyList tokenLogprobs, IReadOnlyList tokens, IReadOnlyList> topLogprobs, IDictionary serializedAdditionalRawData) - { - TextOffset = textOffset; - TokenLogprobs = tokenLogprobs; - Tokens = tokens; - TopLogprobs = topLogprobs; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + TextOffset = new ChangeTrackingList(); + TokenLogprobs = new ChangeTrackingList(); + Tokens = new ChangeTrackingList(); + TopLogprobs = new ChangeTrackingList>(); + } - public IReadOnlyList TextOffset { get; } - public IReadOnlyList TokenLogprobs { get; } - public IReadOnlyList Tokens { get; } - public IReadOnlyList> TopLogprobs { get; } + internal InternalCreateCompletionResponseChoiceLogprobs(IReadOnlyList textOffset, IReadOnlyList tokenLogprobs, IReadOnlyList tokens, IReadOnlyList> topLogprobs, IDictionary serializedAdditionalRawData) + { + TextOffset = textOffset; + TokenLogprobs = tokenLogprobs; + Tokens = tokens; + TopLogprobs = topLogprobs; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IReadOnlyList TextOffset { get; } + public IReadOnlyList TokenLogprobs { get; } + public IReadOnlyList Tokens { get; } + public IReadOnlyList> TopLogprobs { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateCompletionResponseObject.cs b/src/Generated/Models/InternalCreateCompletionResponseObject.cs index 8dfbd347..6e18e220 100644 --- a/src/Generated/Models/InternalCreateCompletionResponseObject.cs +++ b/src/Generated/Models/InternalCreateCompletionResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.LegacyCompletions +namespace OpenAI.LegacyCompletions; + +internal readonly partial struct InternalCreateCompletionResponseObject : IEquatable { - internal readonly partial struct InternalCreateCompletionResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateCompletionResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateCompletionResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TextCompletionValue = "text_completion"; + private const string TextCompletionValue = "text_completion"; - public static InternalCreateCompletionResponseObject TextCompletion { get; } = new InternalCreateCompletionResponseObject(TextCompletionValue); - public static bool operator ==(InternalCreateCompletionResponseObject left, InternalCreateCompletionResponseObject right) => left.Equals(right); - public static bool operator !=(InternalCreateCompletionResponseObject left, InternalCreateCompletionResponseObject right) => !left.Equals(right); - public static implicit operator InternalCreateCompletionResponseObject(string value) => new InternalCreateCompletionResponseObject(value); + public static InternalCreateCompletionResponseObject TextCompletion { get; } = new InternalCreateCompletionResponseObject(TextCompletionValue); + public static bool operator ==(InternalCreateCompletionResponseObject left, InternalCreateCompletionResponseObject right) => left.Equals(right); + public static bool operator !=(InternalCreateCompletionResponseObject left, InternalCreateCompletionResponseObject right) => !left.Equals(right); + public static implicit operator InternalCreateCompletionResponseObject(string value) => new InternalCreateCompletionResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateCompletionResponseObject other && Equals(other); - public bool Equals(InternalCreateCompletionResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateCompletionResponseObject other && Equals(other); + public bool Equals(InternalCreateCompletionResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateEmbeddingRequestEncodingFormat.cs b/src/Generated/Models/InternalCreateEmbeddingRequestEncodingFormat.cs index 6f59eb8e..ee5d9744 100644 --- a/src/Generated/Models/InternalCreateEmbeddingRequestEncodingFormat.cs +++ b/src/Generated/Models/InternalCreateEmbeddingRequestEncodingFormat.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +internal readonly partial struct InternalCreateEmbeddingRequestEncodingFormat : IEquatable { - internal readonly partial struct InternalCreateEmbeddingRequestEncodingFormat : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateEmbeddingRequestEncodingFormat(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateEmbeddingRequestEncodingFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FloatValue = "float"; - private const string Base64Value = "base64"; + private const string FloatValue = "float"; + private const string Base64Value = "base64"; - public static InternalCreateEmbeddingRequestEncodingFormat Float { get; } = new InternalCreateEmbeddingRequestEncodingFormat(FloatValue); - public static InternalCreateEmbeddingRequestEncodingFormat Base64 { get; } = new InternalCreateEmbeddingRequestEncodingFormat(Base64Value); - public static bool operator ==(InternalCreateEmbeddingRequestEncodingFormat left, InternalCreateEmbeddingRequestEncodingFormat right) => left.Equals(right); - public static bool operator !=(InternalCreateEmbeddingRequestEncodingFormat left, InternalCreateEmbeddingRequestEncodingFormat right) => !left.Equals(right); - public static implicit operator InternalCreateEmbeddingRequestEncodingFormat(string value) => new InternalCreateEmbeddingRequestEncodingFormat(value); + public static InternalCreateEmbeddingRequestEncodingFormat Float { get; } = new InternalCreateEmbeddingRequestEncodingFormat(FloatValue); + public static InternalCreateEmbeddingRequestEncodingFormat Base64 { get; } = new InternalCreateEmbeddingRequestEncodingFormat(Base64Value); + public static bool operator ==(InternalCreateEmbeddingRequestEncodingFormat left, InternalCreateEmbeddingRequestEncodingFormat right) => left.Equals(right); + public static bool operator !=(InternalCreateEmbeddingRequestEncodingFormat left, InternalCreateEmbeddingRequestEncodingFormat right) => !left.Equals(right); + public static implicit operator InternalCreateEmbeddingRequestEncodingFormat(string value) => new InternalCreateEmbeddingRequestEncodingFormat(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateEmbeddingRequestEncodingFormat other && Equals(other); - public bool Equals(InternalCreateEmbeddingRequestEncodingFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateEmbeddingRequestEncodingFormat other && Equals(other); + public bool Equals(InternalCreateEmbeddingRequestEncodingFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateEmbeddingRequestModel.cs b/src/Generated/Models/InternalCreateEmbeddingRequestModel.cs index 98fa114a..9f527e74 100644 --- a/src/Generated/Models/InternalCreateEmbeddingRequestModel.cs +++ b/src/Generated/Models/InternalCreateEmbeddingRequestModel.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +internal readonly partial struct InternalCreateEmbeddingRequestModel : IEquatable { - internal readonly partial struct InternalCreateEmbeddingRequestModel : IEquatable + private readonly string _value; + + public InternalCreateEmbeddingRequestModel(string value) { - private readonly string _value; - - public InternalCreateEmbeddingRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string TextEmbeddingAda002Value = "text-embedding-ada-002"; - private const string TextEmbedding3SmallValue = "text-embedding-3-small"; - private const string TextEmbedding3LargeValue = "text-embedding-3-large"; - - public static InternalCreateEmbeddingRequestModel TextEmbeddingAda002 { get; } = new InternalCreateEmbeddingRequestModel(TextEmbeddingAda002Value); - public static InternalCreateEmbeddingRequestModel TextEmbedding3Small { get; } = new InternalCreateEmbeddingRequestModel(TextEmbedding3SmallValue); - public static InternalCreateEmbeddingRequestModel TextEmbedding3Large { get; } = new InternalCreateEmbeddingRequestModel(TextEmbedding3LargeValue); - public static bool operator ==(InternalCreateEmbeddingRequestModel left, InternalCreateEmbeddingRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateEmbeddingRequestModel left, InternalCreateEmbeddingRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateEmbeddingRequestModel(string value) => new InternalCreateEmbeddingRequestModel(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateEmbeddingRequestModel other && Equals(other); - public bool Equals(InternalCreateEmbeddingRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string TextEmbeddingAda002Value = "text-embedding-ada-002"; + private const string TextEmbedding3SmallValue = "text-embedding-3-small"; + private const string TextEmbedding3LargeValue = "text-embedding-3-large"; + + public static InternalCreateEmbeddingRequestModel TextEmbeddingAda002 { get; } = new InternalCreateEmbeddingRequestModel(TextEmbeddingAda002Value); + public static InternalCreateEmbeddingRequestModel TextEmbedding3Small { get; } = new InternalCreateEmbeddingRequestModel(TextEmbedding3SmallValue); + public static InternalCreateEmbeddingRequestModel TextEmbedding3Large { get; } = new InternalCreateEmbeddingRequestModel(TextEmbedding3LargeValue); + public static bool operator ==(InternalCreateEmbeddingRequestModel left, InternalCreateEmbeddingRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateEmbeddingRequestModel left, InternalCreateEmbeddingRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateEmbeddingRequestModel(string value) => new InternalCreateEmbeddingRequestModel(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateEmbeddingRequestModel other && Equals(other); + public bool Equals(InternalCreateEmbeddingRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateEmbeddingResponseObject.cs b/src/Generated/Models/InternalCreateEmbeddingResponseObject.cs index dc8b3863..78b39a3b 100644 --- a/src/Generated/Models/InternalCreateEmbeddingResponseObject.cs +++ b/src/Generated/Models/InternalCreateEmbeddingResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +internal readonly partial struct InternalCreateEmbeddingResponseObject : IEquatable { - internal readonly partial struct InternalCreateEmbeddingResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateEmbeddingResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateEmbeddingResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalCreateEmbeddingResponseObject List { get; } = new InternalCreateEmbeddingResponseObject(ListValue); - public static bool operator ==(InternalCreateEmbeddingResponseObject left, InternalCreateEmbeddingResponseObject right) => left.Equals(right); - public static bool operator !=(InternalCreateEmbeddingResponseObject left, InternalCreateEmbeddingResponseObject right) => !left.Equals(right); - public static implicit operator InternalCreateEmbeddingResponseObject(string value) => new InternalCreateEmbeddingResponseObject(value); + public static InternalCreateEmbeddingResponseObject List { get; } = new InternalCreateEmbeddingResponseObject(ListValue); + public static bool operator ==(InternalCreateEmbeddingResponseObject left, InternalCreateEmbeddingResponseObject right) => left.Equals(right); + public static bool operator !=(InternalCreateEmbeddingResponseObject left, InternalCreateEmbeddingResponseObject right) => !left.Equals(right); + public static implicit operator InternalCreateEmbeddingResponseObject(string value) => new InternalCreateEmbeddingResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateEmbeddingResponseObject other && Equals(other); - public bool Equals(InternalCreateEmbeddingResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateEmbeddingResponseObject other && Equals(other); + public bool Equals(InternalCreateEmbeddingResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateFineTuningJobRequestModel.cs b/src/Generated/Models/InternalCreateFineTuningJobRequestModel.cs index e85d5c33..957a4592 100644 --- a/src/Generated/Models/InternalCreateFineTuningJobRequestModel.cs +++ b/src/Generated/Models/InternalCreateFineTuningJobRequestModel.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct InternalCreateFineTuningJobRequestModel : IEquatable { - internal readonly partial struct InternalCreateFineTuningJobRequestModel : IEquatable + private readonly string _value; + + public InternalCreateFineTuningJobRequestModel(string value) { - private readonly string _value; - - public InternalCreateFineTuningJobRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string Babbage002Value = "babbage-002"; - private const string Davinci002Value = "davinci-002"; - private const string Gpt35TurboValue = "gpt-3.5-turbo"; - private const string Gpt4oMiniValue = "gpt-4o-mini"; - - public static InternalCreateFineTuningJobRequestModel Babbage002 { get; } = new InternalCreateFineTuningJobRequestModel(Babbage002Value); - public static InternalCreateFineTuningJobRequestModel Davinci002 { get; } = new InternalCreateFineTuningJobRequestModel(Davinci002Value); - public static InternalCreateFineTuningJobRequestModel Gpt35Turbo { get; } = new InternalCreateFineTuningJobRequestModel(Gpt35TurboValue); - public static InternalCreateFineTuningJobRequestModel Gpt4oMini { get; } = new InternalCreateFineTuningJobRequestModel(Gpt4oMiniValue); - public static bool operator ==(InternalCreateFineTuningJobRequestModel left, InternalCreateFineTuningJobRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateFineTuningJobRequestModel left, InternalCreateFineTuningJobRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateFineTuningJobRequestModel(string value) => new InternalCreateFineTuningJobRequestModel(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateFineTuningJobRequestModel other && Equals(other); - public bool Equals(InternalCreateFineTuningJobRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string Babbage002Value = "babbage-002"; + private const string Davinci002Value = "davinci-002"; + private const string Gpt35TurboValue = "gpt-3.5-turbo"; + private const string Gpt4oMiniValue = "gpt-4o-mini"; + + public static InternalCreateFineTuningJobRequestModel Babbage002 { get; } = new InternalCreateFineTuningJobRequestModel(Babbage002Value); + public static InternalCreateFineTuningJobRequestModel Davinci002 { get; } = new InternalCreateFineTuningJobRequestModel(Davinci002Value); + public static InternalCreateFineTuningJobRequestModel Gpt35Turbo { get; } = new InternalCreateFineTuningJobRequestModel(Gpt35TurboValue); + public static InternalCreateFineTuningJobRequestModel Gpt4oMini { get; } = new InternalCreateFineTuningJobRequestModel(Gpt4oMiniValue); + public static bool operator ==(InternalCreateFineTuningJobRequestModel left, InternalCreateFineTuningJobRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateFineTuningJobRequestModel left, InternalCreateFineTuningJobRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateFineTuningJobRequestModel(string value) => new InternalCreateFineTuningJobRequestModel(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateFineTuningJobRequestModel other && Equals(other); + public bool Equals(InternalCreateFineTuningJobRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.Serialization.cs b/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.Serialization.cs index b17e11cf..5b07bf64 100644 --- a/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.Serialization.cs +++ b/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.Serialization.cs @@ -8,197 +8,196 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalCreateFineTuningJobRequestWandbIntegrationWandb : IJsonModel { - internal partial class InternalCreateFineTuningJobRequestWandbIntegrationWandb : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("project") != true) + { + writer.WritePropertyName("project"u8); + writer.WriteStringValue(Project); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + if (Name != null) { - throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support writing '{format}' format."); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("project") != true) + else { - writer.WritePropertyName("project"u8); - writer.WriteStringValue(Project); + writer.WriteNull("name"); } - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + } + if (SerializedAdditionalRawData?.ContainsKey("entity") != true && Optional.IsDefined(Entity)) + { + if (Entity != null) { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } + writer.WritePropertyName("entity"u8); + writer.WriteStringValue(Entity); } - if (SerializedAdditionalRawData?.ContainsKey("entity") != true && Optional.IsDefined(Entity)) + else { - if (Entity != null) - { - writer.WritePropertyName("entity"u8); - writer.WriteStringValue(Entity); - } - else - { - writer.WriteNull("entity"); - } + writer.WriteNull("entity"); } - if (SerializedAdditionalRawData?.ContainsKey("tags") != true && Optional.IsCollectionDefined(Tags)) + } + if (SerializedAdditionalRawData?.ContainsKey("tags") != true && Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartArray(); + foreach (var item in Tags) { - writer.WritePropertyName("tags"u8); - writer.WriteStartArray(); - foreach (var item in Tags) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateFineTuningJobRequestWandbIntegrationWandb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateFineTuningJobRequestWandbIntegrationWandb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support reading '{format}' format."); } - internal static InternalCreateFineTuningJobRequestWandbIntegrationWandb DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalCreateFineTuningJobRequestWandbIntegrationWandb DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string project = default; + string name = default; + string entity = default; + IList tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("project"u8)) { - return null; + project = property.Value.GetString(); + continue; } - string project = default; - string name = default; - string entity = default; - IList tags = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("project"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - project = property.Value.GetString(); + name = null; continue; } - if (property.NameEquals("name"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("entity"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("entity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - entity = null; - continue; - } - entity = property.Value.GetString(); + entity = null; continue; } - if (property.NameEquals("tags"u8)) + entity = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - tags = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + tags = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateFineTuningJobRequestWandbIntegrationWandb(project, name, entity, tags ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateFineTuningJobRequestWandbIntegrationWandb(project, name, entity, tags ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalCreateFineTuningJobRequestWandbIntegrationWandb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateFineTuningJobRequestWandbIntegrationWandb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateFineTuningJobRequestWandbIntegrationWandb FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateFineTuningJobRequestWandbIntegrationWandb)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateFineTuningJobRequestWandbIntegrationWandb FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.cs b/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.cs index bd389026..28c3ff79 100644 --- a/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.cs +++ b/src/Generated/Models/InternalCreateFineTuningJobRequestWandbIntegrationWandb.cs @@ -5,33 +5,32 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalCreateFineTuningJobRequestWandbIntegrationWandb { - internal partial class InternalCreateFineTuningJobRequestWandbIntegrationWandb + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateFineTuningJobRequestWandbIntegrationWandb(string project) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateFineTuningJobRequestWandbIntegrationWandb(string project) - { - Argument.AssertNotNull(project, nameof(project)); + Argument.AssertNotNull(project, nameof(project)); - Project = project; - Tags = new ChangeTrackingList(); - } + Project = project; + Tags = new ChangeTrackingList(); + } - internal InternalCreateFineTuningJobRequestWandbIntegrationWandb(string project, string name, string entity, IList tags, IDictionary serializedAdditionalRawData) - { - Project = project; - Name = name; - Entity = entity; - Tags = tags; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalCreateFineTuningJobRequestWandbIntegrationWandb(string project, string name, string entity, IList tags, IDictionary serializedAdditionalRawData) + { + Project = project; + Name = name; + Entity = entity; + Tags = tags; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal InternalCreateFineTuningJobRequestWandbIntegrationWandb() - { - } - public string Name { get; set; } - public string Entity { get; set; } - public IList Tags { get; } + internal InternalCreateFineTuningJobRequestWandbIntegrationWandb() + { } -} + public string Name { get; set; } + public string Entity { get; set; } + public IList Tags { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateImageEditRequestModel.cs b/src/Generated/Models/InternalCreateImageEditRequestModel.cs index c1ae8ba5..a91b7322 100644 --- a/src/Generated/Models/InternalCreateImageEditRequestModel.cs +++ b/src/Generated/Models/InternalCreateImageEditRequestModel.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal readonly partial struct InternalCreateImageEditRequestModel : IEquatable { - internal readonly partial struct InternalCreateImageEditRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateImageEditRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateImageEditRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string DallE2Value = "dall-e-2"; + private const string DallE2Value = "dall-e-2"; - public static InternalCreateImageEditRequestModel DallE2 { get; } = new InternalCreateImageEditRequestModel(DallE2Value); - public static bool operator ==(InternalCreateImageEditRequestModel left, InternalCreateImageEditRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateImageEditRequestModel left, InternalCreateImageEditRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateImageEditRequestModel(string value) => new InternalCreateImageEditRequestModel(value); + public static InternalCreateImageEditRequestModel DallE2 { get; } = new InternalCreateImageEditRequestModel(DallE2Value); + public static bool operator ==(InternalCreateImageEditRequestModel left, InternalCreateImageEditRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateImageEditRequestModel left, InternalCreateImageEditRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateImageEditRequestModel(string value) => new InternalCreateImageEditRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateImageEditRequestModel other && Equals(other); - public bool Equals(InternalCreateImageEditRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateImageEditRequestModel other && Equals(other); + public bool Equals(InternalCreateImageEditRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateImageEditRequestResponseFormat.cs b/src/Generated/Models/InternalCreateImageEditRequestResponseFormat.cs index 7da85fee..7cc90437 100644 --- a/src/Generated/Models/InternalCreateImageEditRequestResponseFormat.cs +++ b/src/Generated/Models/InternalCreateImageEditRequestResponseFormat.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal readonly partial struct InternalCreateImageEditRequestResponseFormat : IEquatable { - internal readonly partial struct InternalCreateImageEditRequestResponseFormat : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateImageEditRequestResponseFormat(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateImageEditRequestResponseFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string UrlValue = "url"; - private const string B64JsonValue = "b64_json"; + private const string UrlValue = "url"; + private const string B64JsonValue = "b64_json"; - public static InternalCreateImageEditRequestResponseFormat Url { get; } = new InternalCreateImageEditRequestResponseFormat(UrlValue); - public static InternalCreateImageEditRequestResponseFormat B64Json { get; } = new InternalCreateImageEditRequestResponseFormat(B64JsonValue); - public static bool operator ==(InternalCreateImageEditRequestResponseFormat left, InternalCreateImageEditRequestResponseFormat right) => left.Equals(right); - public static bool operator !=(InternalCreateImageEditRequestResponseFormat left, InternalCreateImageEditRequestResponseFormat right) => !left.Equals(right); - public static implicit operator InternalCreateImageEditRequestResponseFormat(string value) => new InternalCreateImageEditRequestResponseFormat(value); + public static InternalCreateImageEditRequestResponseFormat Url { get; } = new InternalCreateImageEditRequestResponseFormat(UrlValue); + public static InternalCreateImageEditRequestResponseFormat B64Json { get; } = new InternalCreateImageEditRequestResponseFormat(B64JsonValue); + public static bool operator ==(InternalCreateImageEditRequestResponseFormat left, InternalCreateImageEditRequestResponseFormat right) => left.Equals(right); + public static bool operator !=(InternalCreateImageEditRequestResponseFormat left, InternalCreateImageEditRequestResponseFormat right) => !left.Equals(right); + public static implicit operator InternalCreateImageEditRequestResponseFormat(string value) => new InternalCreateImageEditRequestResponseFormat(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateImageEditRequestResponseFormat other && Equals(other); - public bool Equals(InternalCreateImageEditRequestResponseFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateImageEditRequestResponseFormat other && Equals(other); + public bool Equals(InternalCreateImageEditRequestResponseFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateImageEditRequestSize.cs b/src/Generated/Models/InternalCreateImageEditRequestSize.cs index 122d3fc3..dd5c5d0d 100644 --- a/src/Generated/Models/InternalCreateImageEditRequestSize.cs +++ b/src/Generated/Models/InternalCreateImageEditRequestSize.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal readonly partial struct InternalCreateImageEditRequestSize : IEquatable { - internal readonly partial struct InternalCreateImageEditRequestSize : IEquatable + private readonly string _value; + + public InternalCreateImageEditRequestSize(string value) { - private readonly string _value; - - public InternalCreateImageEditRequestSize(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string _256x256Value = "256x256"; - private const string _512x512Value = "512x512"; - private const string _1024x1024Value = "1024x1024"; - - public static InternalCreateImageEditRequestSize _256x256 { get; } = new InternalCreateImageEditRequestSize(_256x256Value); - public static InternalCreateImageEditRequestSize _512x512 { get; } = new InternalCreateImageEditRequestSize(_512x512Value); - public static InternalCreateImageEditRequestSize _1024x1024 { get; } = new InternalCreateImageEditRequestSize(_1024x1024Value); - public static bool operator ==(InternalCreateImageEditRequestSize left, InternalCreateImageEditRequestSize right) => left.Equals(right); - public static bool operator !=(InternalCreateImageEditRequestSize left, InternalCreateImageEditRequestSize right) => !left.Equals(right); - public static implicit operator InternalCreateImageEditRequestSize(string value) => new InternalCreateImageEditRequestSize(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateImageEditRequestSize other && Equals(other); - public bool Equals(InternalCreateImageEditRequestSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string _256x256Value = "256x256"; + private const string _512x512Value = "512x512"; + private const string _1024x1024Value = "1024x1024"; + + public static InternalCreateImageEditRequestSize _256x256 { get; } = new InternalCreateImageEditRequestSize(_256x256Value); + public static InternalCreateImageEditRequestSize _512x512 { get; } = new InternalCreateImageEditRequestSize(_512x512Value); + public static InternalCreateImageEditRequestSize _1024x1024 { get; } = new InternalCreateImageEditRequestSize(_1024x1024Value); + public static bool operator ==(InternalCreateImageEditRequestSize left, InternalCreateImageEditRequestSize right) => left.Equals(right); + public static bool operator !=(InternalCreateImageEditRequestSize left, InternalCreateImageEditRequestSize right) => !left.Equals(right); + public static implicit operator InternalCreateImageEditRequestSize(string value) => new InternalCreateImageEditRequestSize(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateImageEditRequestSize other && Equals(other); + public bool Equals(InternalCreateImageEditRequestSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateImageRequestModel.cs b/src/Generated/Models/InternalCreateImageRequestModel.cs index a43ec9fc..d71f7d06 100644 --- a/src/Generated/Models/InternalCreateImageRequestModel.cs +++ b/src/Generated/Models/InternalCreateImageRequestModel.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal readonly partial struct InternalCreateImageRequestModel : IEquatable { - internal readonly partial struct InternalCreateImageRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateImageRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateImageRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string DallE2Value = "dall-e-2"; - private const string DallE3Value = "dall-e-3"; + private const string DallE2Value = "dall-e-2"; + private const string DallE3Value = "dall-e-3"; - public static InternalCreateImageRequestModel DallE2 { get; } = new InternalCreateImageRequestModel(DallE2Value); - public static InternalCreateImageRequestModel DallE3 { get; } = new InternalCreateImageRequestModel(DallE3Value); - public static bool operator ==(InternalCreateImageRequestModel left, InternalCreateImageRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateImageRequestModel left, InternalCreateImageRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateImageRequestModel(string value) => new InternalCreateImageRequestModel(value); + public static InternalCreateImageRequestModel DallE2 { get; } = new InternalCreateImageRequestModel(DallE2Value); + public static InternalCreateImageRequestModel DallE3 { get; } = new InternalCreateImageRequestModel(DallE3Value); + public static bool operator ==(InternalCreateImageRequestModel left, InternalCreateImageRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateImageRequestModel left, InternalCreateImageRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateImageRequestModel(string value) => new InternalCreateImageRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateImageRequestModel other && Equals(other); - public bool Equals(InternalCreateImageRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateImageRequestModel other && Equals(other); + public bool Equals(InternalCreateImageRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateImageVariationRequestModel.cs b/src/Generated/Models/InternalCreateImageVariationRequestModel.cs index 2f57438b..0b370ccd 100644 --- a/src/Generated/Models/InternalCreateImageVariationRequestModel.cs +++ b/src/Generated/Models/InternalCreateImageVariationRequestModel.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal readonly partial struct InternalCreateImageVariationRequestModel : IEquatable { - internal readonly partial struct InternalCreateImageVariationRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateImageVariationRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateImageVariationRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string DallE2Value = "dall-e-2"; + private const string DallE2Value = "dall-e-2"; - public static InternalCreateImageVariationRequestModel DallE2 { get; } = new InternalCreateImageVariationRequestModel(DallE2Value); - public static bool operator ==(InternalCreateImageVariationRequestModel left, InternalCreateImageVariationRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateImageVariationRequestModel left, InternalCreateImageVariationRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateImageVariationRequestModel(string value) => new InternalCreateImageVariationRequestModel(value); + public static InternalCreateImageVariationRequestModel DallE2 { get; } = new InternalCreateImageVariationRequestModel(DallE2Value); + public static bool operator ==(InternalCreateImageVariationRequestModel left, InternalCreateImageVariationRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateImageVariationRequestModel left, InternalCreateImageVariationRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateImageVariationRequestModel(string value) => new InternalCreateImageVariationRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateImageVariationRequestModel other && Equals(other); - public bool Equals(InternalCreateImageVariationRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateImageVariationRequestModel other && Equals(other); + public bool Equals(InternalCreateImageVariationRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateImageVariationRequestResponseFormat.cs b/src/Generated/Models/InternalCreateImageVariationRequestResponseFormat.cs index bb1ed33e..2e603278 100644 --- a/src/Generated/Models/InternalCreateImageVariationRequestResponseFormat.cs +++ b/src/Generated/Models/InternalCreateImageVariationRequestResponseFormat.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal readonly partial struct InternalCreateImageVariationRequestResponseFormat : IEquatable { - internal readonly partial struct InternalCreateImageVariationRequestResponseFormat : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateImageVariationRequestResponseFormat(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateImageVariationRequestResponseFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string UrlValue = "url"; - private const string B64JsonValue = "b64_json"; + private const string UrlValue = "url"; + private const string B64JsonValue = "b64_json"; - public static InternalCreateImageVariationRequestResponseFormat Url { get; } = new InternalCreateImageVariationRequestResponseFormat(UrlValue); - public static InternalCreateImageVariationRequestResponseFormat B64Json { get; } = new InternalCreateImageVariationRequestResponseFormat(B64JsonValue); - public static bool operator ==(InternalCreateImageVariationRequestResponseFormat left, InternalCreateImageVariationRequestResponseFormat right) => left.Equals(right); - public static bool operator !=(InternalCreateImageVariationRequestResponseFormat left, InternalCreateImageVariationRequestResponseFormat right) => !left.Equals(right); - public static implicit operator InternalCreateImageVariationRequestResponseFormat(string value) => new InternalCreateImageVariationRequestResponseFormat(value); + public static InternalCreateImageVariationRequestResponseFormat Url { get; } = new InternalCreateImageVariationRequestResponseFormat(UrlValue); + public static InternalCreateImageVariationRequestResponseFormat B64Json { get; } = new InternalCreateImageVariationRequestResponseFormat(B64JsonValue); + public static bool operator ==(InternalCreateImageVariationRequestResponseFormat left, InternalCreateImageVariationRequestResponseFormat right) => left.Equals(right); + public static bool operator !=(InternalCreateImageVariationRequestResponseFormat left, InternalCreateImageVariationRequestResponseFormat right) => !left.Equals(right); + public static implicit operator InternalCreateImageVariationRequestResponseFormat(string value) => new InternalCreateImageVariationRequestResponseFormat(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateImageVariationRequestResponseFormat other && Equals(other); - public bool Equals(InternalCreateImageVariationRequestResponseFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateImageVariationRequestResponseFormat other && Equals(other); + public bool Equals(InternalCreateImageVariationRequestResponseFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateImageVariationRequestSize.cs b/src/Generated/Models/InternalCreateImageVariationRequestSize.cs index 8a60593b..07c430c5 100644 --- a/src/Generated/Models/InternalCreateImageVariationRequestSize.cs +++ b/src/Generated/Models/InternalCreateImageVariationRequestSize.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Images +namespace OpenAI.Images; + +internal readonly partial struct InternalCreateImageVariationRequestSize : IEquatable { - internal readonly partial struct InternalCreateImageVariationRequestSize : IEquatable + private readonly string _value; + + public InternalCreateImageVariationRequestSize(string value) { - private readonly string _value; - - public InternalCreateImageVariationRequestSize(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string _256x256Value = "256x256"; - private const string _512x512Value = "512x512"; - private const string _1024x1024Value = "1024x1024"; - - public static InternalCreateImageVariationRequestSize _256x256 { get; } = new InternalCreateImageVariationRequestSize(_256x256Value); - public static InternalCreateImageVariationRequestSize _512x512 { get; } = new InternalCreateImageVariationRequestSize(_512x512Value); - public static InternalCreateImageVariationRequestSize _1024x1024 { get; } = new InternalCreateImageVariationRequestSize(_1024x1024Value); - public static bool operator ==(InternalCreateImageVariationRequestSize left, InternalCreateImageVariationRequestSize right) => left.Equals(right); - public static bool operator !=(InternalCreateImageVariationRequestSize left, InternalCreateImageVariationRequestSize right) => !left.Equals(right); - public static implicit operator InternalCreateImageVariationRequestSize(string value) => new InternalCreateImageVariationRequestSize(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateImageVariationRequestSize other && Equals(other); - public bool Equals(InternalCreateImageVariationRequestSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string _256x256Value = "256x256"; + private const string _512x512Value = "512x512"; + private const string _1024x1024Value = "1024x1024"; + + public static InternalCreateImageVariationRequestSize _256x256 { get; } = new InternalCreateImageVariationRequestSize(_256x256Value); + public static InternalCreateImageVariationRequestSize _512x512 { get; } = new InternalCreateImageVariationRequestSize(_512x512Value); + public static InternalCreateImageVariationRequestSize _1024x1024 { get; } = new InternalCreateImageVariationRequestSize(_1024x1024Value); + public static bool operator ==(InternalCreateImageVariationRequestSize left, InternalCreateImageVariationRequestSize right) => left.Equals(right); + public static bool operator !=(InternalCreateImageVariationRequestSize left, InternalCreateImageVariationRequestSize right) => !left.Equals(right); + public static implicit operator InternalCreateImageVariationRequestSize(string value) => new InternalCreateImageVariationRequestSize(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateImageVariationRequestSize other && Equals(other); + public bool Equals(InternalCreateImageVariationRequestSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateModerationRequestModel.cs b/src/Generated/Models/InternalCreateModerationRequestModel.cs index f5869681..da6708c7 100644 --- a/src/Generated/Models/InternalCreateModerationRequestModel.cs +++ b/src/Generated/Models/InternalCreateModerationRequestModel.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +internal readonly partial struct InternalCreateModerationRequestModel : IEquatable { - internal readonly partial struct InternalCreateModerationRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateModerationRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateModerationRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TextModerationLatestValue = "text-moderation-latest"; - private const string TextModerationStableValue = "text-moderation-stable"; + private const string TextModerationLatestValue = "text-moderation-latest"; + private const string TextModerationStableValue = "text-moderation-stable"; - public static InternalCreateModerationRequestModel TextModerationLatest { get; } = new InternalCreateModerationRequestModel(TextModerationLatestValue); - public static InternalCreateModerationRequestModel TextModerationStable { get; } = new InternalCreateModerationRequestModel(TextModerationStableValue); - public static bool operator ==(InternalCreateModerationRequestModel left, InternalCreateModerationRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateModerationRequestModel left, InternalCreateModerationRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateModerationRequestModel(string value) => new InternalCreateModerationRequestModel(value); + public static InternalCreateModerationRequestModel TextModerationLatest { get; } = new InternalCreateModerationRequestModel(TextModerationLatestValue); + public static InternalCreateModerationRequestModel TextModerationStable { get; } = new InternalCreateModerationRequestModel(TextModerationStableValue); + public static bool operator ==(InternalCreateModerationRequestModel left, InternalCreateModerationRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateModerationRequestModel left, InternalCreateModerationRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateModerationRequestModel(string value) => new InternalCreateModerationRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateModerationRequestModel other && Equals(other); - public bool Equals(InternalCreateModerationRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateModerationRequestModel other && Equals(other); + public bool Equals(InternalCreateModerationRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateRunRequestModel.cs b/src/Generated/Models/InternalCreateRunRequestModel.cs index 27b73a31..3d0553a6 100644 --- a/src/Generated/Models/InternalCreateRunRequestModel.cs +++ b/src/Generated/Models/InternalCreateRunRequestModel.cs @@ -5,74 +5,73 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalCreateRunRequestModel : IEquatable { - internal readonly partial struct InternalCreateRunRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateRunRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateRunRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string Gpt4oValue = "gpt-4o"; - private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; - private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; - private const string Gpt4oMiniValue = "gpt-4o-mini"; - private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; - private const string Gpt4TurboValue = "gpt-4-turbo"; - private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; - private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; - private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; - private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; - private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; - private const string Gpt4Value = "gpt-4"; - private const string Gpt40314Value = "gpt-4-0314"; - private const string Gpt40613Value = "gpt-4-0613"; - private const string Gpt432kValue = "gpt-4-32k"; - private const string Gpt432k0314Value = "gpt-4-32k-0314"; - private const string Gpt432k0613Value = "gpt-4-32k-0613"; - private const string Gpt35TurboValue = "gpt-3.5-turbo"; - private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; - private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; - private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; - private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; - private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; + private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; + private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; + private const string Gpt4oMiniValue = "gpt-4o-mini"; + private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; + private const string Gpt4TurboValue = "gpt-4-turbo"; + private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; + private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; + private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; + private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; + private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; + private const string Gpt4Value = "gpt-4"; + private const string Gpt40314Value = "gpt-4-0314"; + private const string Gpt40613Value = "gpt-4-0613"; + private const string Gpt432kValue = "gpt-4-32k"; + private const string Gpt432k0314Value = "gpt-4-32k-0314"; + private const string Gpt432k0613Value = "gpt-4-32k-0613"; + private const string Gpt35TurboValue = "gpt-3.5-turbo"; + private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; + private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; + private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; + private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; + private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; - public static InternalCreateRunRequestModel Gpt4o { get; } = new InternalCreateRunRequestModel(Gpt4oValue); - public static InternalCreateRunRequestModel Gpt4o20240806 { get; } = new InternalCreateRunRequestModel(Gpt4o20240806Value); - public static InternalCreateRunRequestModel Gpt4o20240513 { get; } = new InternalCreateRunRequestModel(Gpt4o20240513Value); - public static InternalCreateRunRequestModel Gpt4oMini { get; } = new InternalCreateRunRequestModel(Gpt4oMiniValue); - public static InternalCreateRunRequestModel Gpt4oMini20240718 { get; } = new InternalCreateRunRequestModel(Gpt4oMini20240718Value); - public static InternalCreateRunRequestModel Gpt4Turbo { get; } = new InternalCreateRunRequestModel(Gpt4TurboValue); - public static InternalCreateRunRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateRunRequestModel(Gpt4Turbo20240409Value); - public static InternalCreateRunRequestModel Gpt40125Preview { get; } = new InternalCreateRunRequestModel(Gpt40125PreviewValue); - public static InternalCreateRunRequestModel Gpt4TurboPreview { get; } = new InternalCreateRunRequestModel(Gpt4TurboPreviewValue); - public static InternalCreateRunRequestModel Gpt41106Preview { get; } = new InternalCreateRunRequestModel(Gpt41106PreviewValue); - public static InternalCreateRunRequestModel Gpt4VisionPreview { get; } = new InternalCreateRunRequestModel(Gpt4VisionPreviewValue); - public static InternalCreateRunRequestModel Gpt4 { get; } = new InternalCreateRunRequestModel(Gpt4Value); - public static InternalCreateRunRequestModel Gpt40314 { get; } = new InternalCreateRunRequestModel(Gpt40314Value); - public static InternalCreateRunRequestModel Gpt40613 { get; } = new InternalCreateRunRequestModel(Gpt40613Value); - public static InternalCreateRunRequestModel Gpt432k { get; } = new InternalCreateRunRequestModel(Gpt432kValue); - public static InternalCreateRunRequestModel Gpt432k0314 { get; } = new InternalCreateRunRequestModel(Gpt432k0314Value); - public static InternalCreateRunRequestModel Gpt432k0613 { get; } = new InternalCreateRunRequestModel(Gpt432k0613Value); - public static InternalCreateRunRequestModel Gpt35Turbo { get; } = new InternalCreateRunRequestModel(Gpt35TurboValue); - public static InternalCreateRunRequestModel Gpt35Turbo16k { get; } = new InternalCreateRunRequestModel(Gpt35Turbo16kValue); - public static InternalCreateRunRequestModel Gpt35Turbo0613 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo0613Value); - public static InternalCreateRunRequestModel Gpt35Turbo1106 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo1106Value); - public static InternalCreateRunRequestModel Gpt35Turbo0125 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo0125Value); - public static InternalCreateRunRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo16k0613Value); - public static bool operator ==(InternalCreateRunRequestModel left, InternalCreateRunRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateRunRequestModel left, InternalCreateRunRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateRunRequestModel(string value) => new InternalCreateRunRequestModel(value); + public static InternalCreateRunRequestModel Gpt4o { get; } = new InternalCreateRunRequestModel(Gpt4oValue); + public static InternalCreateRunRequestModel Gpt4o20240806 { get; } = new InternalCreateRunRequestModel(Gpt4o20240806Value); + public static InternalCreateRunRequestModel Gpt4o20240513 { get; } = new InternalCreateRunRequestModel(Gpt4o20240513Value); + public static InternalCreateRunRequestModel Gpt4oMini { get; } = new InternalCreateRunRequestModel(Gpt4oMiniValue); + public static InternalCreateRunRequestModel Gpt4oMini20240718 { get; } = new InternalCreateRunRequestModel(Gpt4oMini20240718Value); + public static InternalCreateRunRequestModel Gpt4Turbo { get; } = new InternalCreateRunRequestModel(Gpt4TurboValue); + public static InternalCreateRunRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateRunRequestModel(Gpt4Turbo20240409Value); + public static InternalCreateRunRequestModel Gpt40125Preview { get; } = new InternalCreateRunRequestModel(Gpt40125PreviewValue); + public static InternalCreateRunRequestModel Gpt4TurboPreview { get; } = new InternalCreateRunRequestModel(Gpt4TurboPreviewValue); + public static InternalCreateRunRequestModel Gpt41106Preview { get; } = new InternalCreateRunRequestModel(Gpt41106PreviewValue); + public static InternalCreateRunRequestModel Gpt4VisionPreview { get; } = new InternalCreateRunRequestModel(Gpt4VisionPreviewValue); + public static InternalCreateRunRequestModel Gpt4 { get; } = new InternalCreateRunRequestModel(Gpt4Value); + public static InternalCreateRunRequestModel Gpt40314 { get; } = new InternalCreateRunRequestModel(Gpt40314Value); + public static InternalCreateRunRequestModel Gpt40613 { get; } = new InternalCreateRunRequestModel(Gpt40613Value); + public static InternalCreateRunRequestModel Gpt432k { get; } = new InternalCreateRunRequestModel(Gpt432kValue); + public static InternalCreateRunRequestModel Gpt432k0314 { get; } = new InternalCreateRunRequestModel(Gpt432k0314Value); + public static InternalCreateRunRequestModel Gpt432k0613 { get; } = new InternalCreateRunRequestModel(Gpt432k0613Value); + public static InternalCreateRunRequestModel Gpt35Turbo { get; } = new InternalCreateRunRequestModel(Gpt35TurboValue); + public static InternalCreateRunRequestModel Gpt35Turbo16k { get; } = new InternalCreateRunRequestModel(Gpt35Turbo16kValue); + public static InternalCreateRunRequestModel Gpt35Turbo0613 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo0613Value); + public static InternalCreateRunRequestModel Gpt35Turbo1106 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo1106Value); + public static InternalCreateRunRequestModel Gpt35Turbo0125 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo0125Value); + public static InternalCreateRunRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateRunRequestModel(Gpt35Turbo16k0613Value); + public static bool operator ==(InternalCreateRunRequestModel left, InternalCreateRunRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateRunRequestModel left, InternalCreateRunRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateRunRequestModel(string value) => new InternalCreateRunRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateRunRequestModel other && Equals(other); - public bool Equals(InternalCreateRunRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateRunRequestModel other && Equals(other); + public bool Equals(InternalCreateRunRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateSpeechRequestModel.cs b/src/Generated/Models/InternalCreateSpeechRequestModel.cs index 795344fd..7974276f 100644 --- a/src/Generated/Models/InternalCreateSpeechRequestModel.cs +++ b/src/Generated/Models/InternalCreateSpeechRequestModel.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal readonly partial struct InternalCreateSpeechRequestModel : IEquatable { - internal readonly partial struct InternalCreateSpeechRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateSpeechRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateSpeechRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string Tts1Value = "tts-1"; - private const string Tts1HdValue = "tts-1-hd"; + private const string Tts1Value = "tts-1"; + private const string Tts1HdValue = "tts-1-hd"; - public static InternalCreateSpeechRequestModel Tts1 { get; } = new InternalCreateSpeechRequestModel(Tts1Value); - public static InternalCreateSpeechRequestModel Tts1Hd { get; } = new InternalCreateSpeechRequestModel(Tts1HdValue); - public static bool operator ==(InternalCreateSpeechRequestModel left, InternalCreateSpeechRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateSpeechRequestModel left, InternalCreateSpeechRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateSpeechRequestModel(string value) => new InternalCreateSpeechRequestModel(value); + public static InternalCreateSpeechRequestModel Tts1 { get; } = new InternalCreateSpeechRequestModel(Tts1Value); + public static InternalCreateSpeechRequestModel Tts1Hd { get; } = new InternalCreateSpeechRequestModel(Tts1HdValue); + public static bool operator ==(InternalCreateSpeechRequestModel left, InternalCreateSpeechRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateSpeechRequestModel left, InternalCreateSpeechRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateSpeechRequestModel(string value) => new InternalCreateSpeechRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateSpeechRequestModel other && Equals(other); - public bool Equals(InternalCreateSpeechRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateSpeechRequestModel other && Equals(other); + public bool Equals(InternalCreateSpeechRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs b/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs index 20185da5..0c5531e5 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequest.Serialization.cs @@ -8,491 +8,490 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadAndRunRequest : IJsonModel { - internal partial class InternalCreateThreadAndRunRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + { + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + } + if (SerializedAdditionalRawData?.ContainsKey("thread") != true && Optional.IsDefined(Thread)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("thread"u8); + writer.WriteObjectValue(Thread, options); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + { + if (Model != null) { - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support writing '{format}' format."); + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + else { - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); + writer.WriteNull("model"); } - if (SerializedAdditionalRawData?.ContainsKey("thread") != true && Optional.IsDefined(Thread)) + } + if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(Instructions)) + { + if (Instructions != null) { - writer.WritePropertyName("thread"u8); - writer.WriteObjectValue(Thread, options); + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + else { - if (Model != null) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); - } - else - { - writer.WriteNull("model"); - } + writer.WriteNull("instructions"); } - if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(Instructions)) + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + { + if (Tools != null) { - if (Instructions != null) + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); - } - else - { - writer.WriteNull("instructions"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + else { - if (Tools != null) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("tools"); - } + writer.WriteNull("tools"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + } + if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + else { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WriteNull("tool_resources"); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("temperature"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(TopP)) + else { - if (TopP != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(TopP.Value); - } - else - { - writer.WriteNull("top_p"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + if (Temperature != null) { - if (Stream != null) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - else - { - writer.WriteNull("stream"); - } + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_prompt_tokens") != true && Optional.IsDefined(MaxPromptTokens)) + else { - if (MaxPromptTokens != null) - { - writer.WritePropertyName("max_prompt_tokens"u8); - writer.WriteNumberValue(MaxPromptTokens.Value); - } - else - { - writer.WriteNull("max_prompt_tokens"); - } + writer.WriteNull("temperature"); } - if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true && Optional.IsDefined(MaxCompletionTokens)) + } + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(TopP)) + { + if (TopP != null) { - if (MaxCompletionTokens != null) - { - writer.WritePropertyName("max_completion_tokens"u8); - writer.WriteNumberValue(MaxCompletionTokens.Value); - } - else - { - writer.WriteNull("max_completion_tokens"); - } + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); } - if (SerializedAdditionalRawData?.ContainsKey("truncation_strategy") != true && Optional.IsDefined(TruncationStrategy)) + else { - if (TruncationStrategy != null) - { - writer.WritePropertyName("truncation_strategy"u8); - writer.WriteObjectValue(TruncationStrategy, options); - } - else - { - writer.WriteNull("truncation_strategy"); - } + writer.WriteNull("top_p"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true && Optional.IsDefined(ToolChoice)) + } + if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + { + if (Stream != null) { - if (ToolChoice != null) - { - writer.WritePropertyName("tool_choice"u8); - writer.WriteObjectValue(ToolChoice, options); - } - else - { - writer.WriteNull("tool_choice"); - } + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); } - if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCalls)) + else { - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCalls.Value); + writer.WriteNull("stream"); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + } + if (SerializedAdditionalRawData?.ContainsKey("max_prompt_tokens") != true && Optional.IsDefined(MaxPromptTokens)) + { + if (MaxPromptTokens != null) { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteObjectValue(ResponseFormat, options); - } - else - { - writer.WriteNull("response_format"); - } + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true && Optional.IsDefined(MaxCompletionTokens)) + { + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("truncation_strategy") != true && Optional.IsDefined(TruncationStrategy)) + { + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true && Optional.IsDefined(ToolChoice)) + { + if (ToolChoice != null) + { + writer.WritePropertyName("tool_choice"u8); + writer.WriteObjectValue(ToolChoice, options); + } + else + { + writer.WriteNull("tool_choice"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCalls)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); + writer.WriteObjectValue(ResponseFormat, options); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("response_format"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateThreadAndRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateThreadAndRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateThreadAndRunRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support reading '{format}' format."); } - internal static InternalCreateThreadAndRunRequest DeserializeInternalCreateThreadAndRunRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateThreadAndRunRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string assistantId = default; - ThreadCreationOptions thread = default; - string model = default; - string instructions = default; - IList tools = default; - ToolResources toolResources = default; - IDictionary metadata = default; - float? temperature = default; - float? topP = default; - bool? stream = default; - int? maxPromptTokens = default; - int? maxCompletionTokens = default; - RunTruncationStrategy truncationStrategy = default; - ToolConstraint toolChoice = default; - bool? parallelToolCalls = default; - AssistantResponseFormat responseFormat = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("assistant_id"u8)) + internal static InternalCreateThreadAndRunRequest DeserializeInternalCreateThreadAndRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string assistantId = default; + ThreadCreationOptions thread = default; + string model = default; + string instructions = default; + IList tools = default; + ToolResources toolResources = default; + IDictionary metadata = default; + float? temperature = default; + float? topP = default; + bool? stream = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + RunTruncationStrategy truncationStrategy = default; + ToolConstraint toolChoice = default; + bool? parallelToolCalls = default; + AssistantResponseFormat responseFormat = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("thread"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - assistantId = property.Value.GetString(); continue; } - if (property.NameEquals("thread"u8)) + thread = ThreadCreationOptions.DeserializeThreadCreationOptions(property.Value, options); + continue; + } + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - thread = ThreadCreationOptions.DeserializeThreadCreationOptions(property.Value, options); + model = null; continue; } - if (property.NameEquals("model"u8)) + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - model = null; - continue; - } - model = property.Value.GetString(); + instructions = null; continue; } - if (property.NameEquals("instructions"u8)) + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); continue; } - if (property.NameEquals("tools"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); } - if (property.NameEquals("tool_resources"u8)) + tools = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + toolResources = null; continue; } - if (property.NameEquals("metadata"u8)) + toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (property.NameEquals("temperature"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); - continue; + dictionary.Add(property0.Name, property0.Value.GetString()); } - if (property.NameEquals("top_p"u8)) + metadata = dictionary; + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); + temperature = null; continue; } - if (property.NameEquals("stream"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - stream = null; - continue; - } - stream = property.Value.GetBoolean(); + topP = null; continue; } - if (property.NameEquals("max_prompt_tokens"u8)) + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxPromptTokens = null; - continue; - } - maxPromptTokens = property.Value.GetInt32(); + stream = null; continue; } - if (property.NameEquals("max_completion_tokens"u8)) + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxCompletionTokens = null; - continue; - } - maxCompletionTokens = property.Value.GetInt32(); + maxPromptTokens = null; continue; } - if (property.NameEquals("truncation_strategy"u8)) + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - truncationStrategy = null; - continue; - } - truncationStrategy = RunTruncationStrategy.DeserializeRunTruncationStrategy(property.Value, options); + maxCompletionTokens = null; continue; } - if (property.NameEquals("tool_choice"u8)) + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolChoice = null; - continue; - } - toolChoice = ToolConstraint.DeserializeToolConstraint(property.Value, options); + truncationStrategy = null; continue; } - if (property.NameEquals("parallel_tool_calls"u8)) + truncationStrategy = RunTruncationStrategy.DeserializeRunTruncationStrategy(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parallelToolCalls = property.Value.GetBoolean(); + toolChoice = null; continue; } - if (property.NameEquals("response_format"u8)) + toolChoice = ToolConstraint.DeserializeToolConstraint(property.Value, options); + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); continue; } - if (true) + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + responseFormat = null; + continue; } + responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateThreadAndRunRequest( - assistantId, - thread, - model, - instructions, - tools ?? new ChangeTrackingList(), - toolResources, - metadata ?? new ChangeTrackingDictionary(), - temperature, - topP, - stream, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - parallelToolCalls, - responseFormat, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateThreadAndRunRequest( + assistantId, + thread, + model, + instructions, + tools ?? new ChangeTrackingList(), + toolResources, + metadata ?? new ChangeTrackingDictionary(), + temperature, + topP, + stream, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + parallelToolCalls, + responseFormat, + serializedAdditionalRawData); + } - InternalCreateThreadAndRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateThreadAndRunRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateThreadAndRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateThreadAndRunRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateThreadAndRunRequest(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateThreadAndRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequest)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateThreadAndRunRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateThreadAndRunRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequest.cs b/src/Generated/Models/InternalCreateThreadAndRunRequest.cs index 5e50cf64..19ca3316 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequest.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequest.cs @@ -5,56 +5,55 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadAndRunRequest { - internal partial class InternalCreateThreadAndRunRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateThreadAndRunRequest(string assistantId) + { + Argument.AssertNotNull(assistantId, nameof(assistantId)); + + AssistantId = assistantId; + Tools = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + internal InternalCreateThreadAndRunRequest(string assistantId, ThreadCreationOptions thread, string model, string instructions, IList tools, ToolResources toolResources, IDictionary metadata, float? temperature, float? topP, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolChoice, bool? parallelToolCalls, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateThreadAndRunRequest(string assistantId) - { - Argument.AssertNotNull(assistantId, nameof(assistantId)); - - AssistantId = assistantId; - Tools = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - internal InternalCreateThreadAndRunRequest(string assistantId, ThreadCreationOptions thread, string model, string instructions, IList tools, ToolResources toolResources, IDictionary metadata, float? temperature, float? topP, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolChoice, bool? parallelToolCalls, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) - { - AssistantId = assistantId; - Thread = thread; - Model = model; - Instructions = instructions; - Tools = tools; - ToolResources = toolResources; - Metadata = metadata; - Temperature = temperature; - TopP = topP; - Stream = stream; - MaxPromptTokens = maxPromptTokens; - MaxCompletionTokens = maxCompletionTokens; - TruncationStrategy = truncationStrategy; - ToolChoice = toolChoice; - ParallelToolCalls = parallelToolCalls; - ResponseFormat = responseFormat; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateThreadAndRunRequest() - { - } - - public string AssistantId { get; } - public ThreadCreationOptions Thread { get; set; } - public string Instructions { get; set; } - public IList Tools { get; set; } - public IDictionary Metadata { get; set; } - public float? Temperature { get; set; } - public float? TopP { get; set; } - public bool? Stream { get; set; } - public int? MaxPromptTokens { get; set; } - public int? MaxCompletionTokens { get; set; } - public RunTruncationStrategy TruncationStrategy { get; set; } - public bool? ParallelToolCalls { get; set; } + AssistantId = assistantId; + Thread = thread; + Model = model; + Instructions = instructions; + Tools = tools; + ToolResources = toolResources; + Metadata = metadata; + Temperature = temperature; + TopP = topP; + Stream = stream; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ParallelToolCalls = parallelToolCalls; + ResponseFormat = responseFormat; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateThreadAndRunRequest() + { + } + + public string AssistantId { get; } + public ThreadCreationOptions Thread { get; set; } + public string Instructions { get; set; } + public IList Tools { get; set; } + public IDictionary Metadata { get; set; } + public float? Temperature { get; set; } + public float? TopP { get; set; } + public bool? Stream { get; set; } + public int? MaxPromptTokens { get; set; } + public int? MaxCompletionTokens { get; set; } + public RunTruncationStrategy TruncationStrategy { get; set; } + public bool? ParallelToolCalls { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs b/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs index 04d84a62..63f1d97e 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequestModel.cs @@ -5,74 +5,73 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalCreateThreadAndRunRequestModel : IEquatable { - internal readonly partial struct InternalCreateThreadAndRunRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateThreadAndRunRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateThreadAndRunRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string Gpt4oValue = "gpt-4o"; - private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; - private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; - private const string Gpt4oMiniValue = "gpt-4o-mini"; - private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; - private const string Gpt4TurboValue = "gpt-4-turbo"; - private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; - private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; - private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; - private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; - private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; - private const string Gpt4Value = "gpt-4"; - private const string Gpt40314Value = "gpt-4-0314"; - private const string Gpt40613Value = "gpt-4-0613"; - private const string Gpt432kValue = "gpt-4-32k"; - private const string Gpt432k0314Value = "gpt-4-32k-0314"; - private const string Gpt432k0613Value = "gpt-4-32k-0613"; - private const string Gpt35TurboValue = "gpt-3.5-turbo"; - private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; - private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; - private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; - private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; - private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; + private const string Gpt4oValue = "gpt-4o"; + private const string Gpt4o20240806Value = "gpt-4o-2024-08-06"; + private const string Gpt4o20240513Value = "gpt-4o-2024-05-13"; + private const string Gpt4oMiniValue = "gpt-4o-mini"; + private const string Gpt4oMini20240718Value = "gpt-4o-mini-2024-07-18"; + private const string Gpt4TurboValue = "gpt-4-turbo"; + private const string Gpt4Turbo20240409Value = "gpt-4-turbo-2024-04-09"; + private const string Gpt40125PreviewValue = "gpt-4-0125-preview"; + private const string Gpt4TurboPreviewValue = "gpt-4-turbo-preview"; + private const string Gpt41106PreviewValue = "gpt-4-1106-preview"; + private const string Gpt4VisionPreviewValue = "gpt-4-vision-preview"; + private const string Gpt4Value = "gpt-4"; + private const string Gpt40314Value = "gpt-4-0314"; + private const string Gpt40613Value = "gpt-4-0613"; + private const string Gpt432kValue = "gpt-4-32k"; + private const string Gpt432k0314Value = "gpt-4-32k-0314"; + private const string Gpt432k0613Value = "gpt-4-32k-0613"; + private const string Gpt35TurboValue = "gpt-3.5-turbo"; + private const string Gpt35Turbo16kValue = "gpt-3.5-turbo-16k"; + private const string Gpt35Turbo0613Value = "gpt-3.5-turbo-0613"; + private const string Gpt35Turbo1106Value = "gpt-3.5-turbo-1106"; + private const string Gpt35Turbo0125Value = "gpt-3.5-turbo-0125"; + private const string Gpt35Turbo16k0613Value = "gpt-3.5-turbo-16k-0613"; - public static InternalCreateThreadAndRunRequestModel Gpt4o { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4oValue); - public static InternalCreateThreadAndRunRequestModel Gpt4o20240806 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4o20240806Value); - public static InternalCreateThreadAndRunRequestModel Gpt4o20240513 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4o20240513Value); - public static InternalCreateThreadAndRunRequestModel Gpt4oMini { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4oMiniValue); - public static InternalCreateThreadAndRunRequestModel Gpt4oMini20240718 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4oMini20240718Value); - public static InternalCreateThreadAndRunRequestModel Gpt4Turbo { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4TurboValue); - public static InternalCreateThreadAndRunRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4Turbo20240409Value); - public static InternalCreateThreadAndRunRequestModel Gpt40125Preview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt40125PreviewValue); - public static InternalCreateThreadAndRunRequestModel Gpt4TurboPreview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4TurboPreviewValue); - public static InternalCreateThreadAndRunRequestModel Gpt41106Preview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt41106PreviewValue); - public static InternalCreateThreadAndRunRequestModel Gpt4VisionPreview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4VisionPreviewValue); - public static InternalCreateThreadAndRunRequestModel Gpt4 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4Value); - public static InternalCreateThreadAndRunRequestModel Gpt40314 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt40314Value); - public static InternalCreateThreadAndRunRequestModel Gpt40613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt40613Value); - public static InternalCreateThreadAndRunRequestModel Gpt432k { get; } = new InternalCreateThreadAndRunRequestModel(Gpt432kValue); - public static InternalCreateThreadAndRunRequestModel Gpt432k0314 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt432k0314Value); - public static InternalCreateThreadAndRunRequestModel Gpt432k0613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt432k0613Value); - public static InternalCreateThreadAndRunRequestModel Gpt35Turbo { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35TurboValue); - public static InternalCreateThreadAndRunRequestModel Gpt35Turbo16k { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo16kValue); - public static InternalCreateThreadAndRunRequestModel Gpt35Turbo0613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo0613Value); - public static InternalCreateThreadAndRunRequestModel Gpt35Turbo1106 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo1106Value); - public static InternalCreateThreadAndRunRequestModel Gpt35Turbo0125 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo0125Value); - public static InternalCreateThreadAndRunRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo16k0613Value); - public static bool operator ==(InternalCreateThreadAndRunRequestModel left, InternalCreateThreadAndRunRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateThreadAndRunRequestModel left, InternalCreateThreadAndRunRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateThreadAndRunRequestModel(string value) => new InternalCreateThreadAndRunRequestModel(value); + public static InternalCreateThreadAndRunRequestModel Gpt4o { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4oValue); + public static InternalCreateThreadAndRunRequestModel Gpt4o20240806 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4o20240806Value); + public static InternalCreateThreadAndRunRequestModel Gpt4o20240513 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4o20240513Value); + public static InternalCreateThreadAndRunRequestModel Gpt4oMini { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4oMiniValue); + public static InternalCreateThreadAndRunRequestModel Gpt4oMini20240718 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4oMini20240718Value); + public static InternalCreateThreadAndRunRequestModel Gpt4Turbo { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4TurboValue); + public static InternalCreateThreadAndRunRequestModel Gpt4Turbo20240409 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4Turbo20240409Value); + public static InternalCreateThreadAndRunRequestModel Gpt40125Preview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt40125PreviewValue); + public static InternalCreateThreadAndRunRequestModel Gpt4TurboPreview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4TurboPreviewValue); + public static InternalCreateThreadAndRunRequestModel Gpt41106Preview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt41106PreviewValue); + public static InternalCreateThreadAndRunRequestModel Gpt4VisionPreview { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4VisionPreviewValue); + public static InternalCreateThreadAndRunRequestModel Gpt4 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt4Value); + public static InternalCreateThreadAndRunRequestModel Gpt40314 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt40314Value); + public static InternalCreateThreadAndRunRequestModel Gpt40613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt40613Value); + public static InternalCreateThreadAndRunRequestModel Gpt432k { get; } = new InternalCreateThreadAndRunRequestModel(Gpt432kValue); + public static InternalCreateThreadAndRunRequestModel Gpt432k0314 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt432k0314Value); + public static InternalCreateThreadAndRunRequestModel Gpt432k0613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt432k0613Value); + public static InternalCreateThreadAndRunRequestModel Gpt35Turbo { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35TurboValue); + public static InternalCreateThreadAndRunRequestModel Gpt35Turbo16k { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo16kValue); + public static InternalCreateThreadAndRunRequestModel Gpt35Turbo0613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo0613Value); + public static InternalCreateThreadAndRunRequestModel Gpt35Turbo1106 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo1106Value); + public static InternalCreateThreadAndRunRequestModel Gpt35Turbo0125 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo0125Value); + public static InternalCreateThreadAndRunRequestModel Gpt35Turbo16k0613 { get; } = new InternalCreateThreadAndRunRequestModel(Gpt35Turbo16k0613Value); + public static bool operator ==(InternalCreateThreadAndRunRequestModel left, InternalCreateThreadAndRunRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateThreadAndRunRequestModel left, InternalCreateThreadAndRunRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateThreadAndRunRequestModel(string value) => new InternalCreateThreadAndRunRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateThreadAndRunRequestModel other && Equals(other); - public bool Equals(InternalCreateThreadAndRunRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateThreadAndRunRequestModel other && Equals(other); + public bool Equals(InternalCreateThreadAndRunRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequestToolChoice.cs b/src/Generated/Models/InternalCreateThreadAndRunRequestToolChoice.cs index 45a467b3..447fd0c4 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequestToolChoice.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequestToolChoice.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalCreateThreadAndRunRequestToolChoice : IEquatable { - internal readonly partial struct InternalCreateThreadAndRunRequestToolChoice : IEquatable + private readonly string _value; + + public InternalCreateThreadAndRunRequestToolChoice(string value) { - private readonly string _value; - - public InternalCreateThreadAndRunRequestToolChoice(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string NoneValue = "none"; - private const string AutoValue = "auto"; - private const string RequiredValue = "required"; - - public static InternalCreateThreadAndRunRequestToolChoice None { get; } = new InternalCreateThreadAndRunRequestToolChoice(NoneValue); - public static InternalCreateThreadAndRunRequestToolChoice Auto { get; } = new InternalCreateThreadAndRunRequestToolChoice(AutoValue); - public static InternalCreateThreadAndRunRequestToolChoice Required { get; } = new InternalCreateThreadAndRunRequestToolChoice(RequiredValue); - public static bool operator ==(InternalCreateThreadAndRunRequestToolChoice left, InternalCreateThreadAndRunRequestToolChoice right) => left.Equals(right); - public static bool operator !=(InternalCreateThreadAndRunRequestToolChoice left, InternalCreateThreadAndRunRequestToolChoice right) => !left.Equals(right); - public static implicit operator InternalCreateThreadAndRunRequestToolChoice(string value) => new InternalCreateThreadAndRunRequestToolChoice(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateThreadAndRunRequestToolChoice other && Equals(other); - public bool Equals(InternalCreateThreadAndRunRequestToolChoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string NoneValue = "none"; + private const string AutoValue = "auto"; + private const string RequiredValue = "required"; + + public static InternalCreateThreadAndRunRequestToolChoice None { get; } = new InternalCreateThreadAndRunRequestToolChoice(NoneValue); + public static InternalCreateThreadAndRunRequestToolChoice Auto { get; } = new InternalCreateThreadAndRunRequestToolChoice(AutoValue); + public static InternalCreateThreadAndRunRequestToolChoice Required { get; } = new InternalCreateThreadAndRunRequestToolChoice(RequiredValue); + public static bool operator ==(InternalCreateThreadAndRunRequestToolChoice left, InternalCreateThreadAndRunRequestToolChoice right) => left.Equals(right); + public static bool operator !=(InternalCreateThreadAndRunRequestToolChoice left, InternalCreateThreadAndRunRequestToolChoice right) => !left.Equals(right); + public static implicit operator InternalCreateThreadAndRunRequestToolChoice(string value) => new InternalCreateThreadAndRunRequestToolChoice(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateThreadAndRunRequestToolChoice other && Equals(other); + public bool Equals(InternalCreateThreadAndRunRequestToolChoice other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.Serialization.cs b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.Serialization.cs index aff6e9e5..2c3031b1 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.Serialization.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadAndRunRequestToolResources : IJsonModel { - internal partial class InternalCreateThreadAndRunRequestToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateThreadAndRunRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateThreadAndRunRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateThreadAndRunRequestToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support reading '{format}' format."); } - internal static InternalCreateThreadAndRunRequestToolResources DeserializeInternalCreateThreadAndRunRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateThreadAndRunRequestToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter codeInterpreter = default; - InternalToolResourcesFileSearchIdsOnly fileSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateThreadAndRunRequestToolResources DeserializeInternalCreateThreadAndRunRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter codeInterpreter = default; + InternalToolResourcesFileSearchIdsOnly fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("code_interpreter"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(property.Value, options); continue; } - if (property.NameEquals("file_search"u8)) + codeInterpreter = InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = InternalToolResourcesFileSearchIdsOnly.DeserializeInternalToolResourcesFileSearchIdsOnly(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = InternalToolResourcesFileSearchIdsOnly.DeserializeInternalToolResourcesFileSearchIdsOnly(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateThreadAndRunRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateThreadAndRunRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); + } - InternalCreateThreadAndRunRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateThreadAndRunRequestToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateThreadAndRunRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateThreadAndRunRequestToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateThreadAndRunRequestToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateThreadAndRunRequestToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateThreadAndRunRequestToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateThreadAndRunRequestToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.cs b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.cs index a07a484a..f523776f 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResources.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadAndRunRequestToolResources { - internal partial class InternalCreateThreadAndRunRequestToolResources + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateThreadAndRunRequestToolResources() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateThreadAndRunRequestToolResources() - { - } - - internal InternalCreateThreadAndRunRequestToolResources(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter codeInterpreter, InternalToolResourcesFileSearchIdsOnly fileSearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } - public InternalToolResourcesFileSearchIdsOnly FileSearch { get; set; } + internal InternalCreateThreadAndRunRequestToolResources(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter codeInterpreter, InternalToolResourcesFileSearchIdsOnly fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } + public InternalToolResourcesFileSearchIdsOnly FileSearch { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.Serialization.cs index 73c8d2c3..f0055eb9 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter : IJsonModel { - internal partial class InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + fileIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.cs b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.cs index ed362ab6..04389cb2 100644 --- a/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.cs +++ b/src/Generated/Models/InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter { - internal partial class InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter() - { - FileIds = new ChangeTrackingList(); - } - - internal InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + } - public IList FileIds { get; } + internal InternalCreateThreadAndRunRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList FileIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadRequestToolResources.Serialization.cs b/src/Generated/Models/InternalCreateThreadRequestToolResources.Serialization.cs index 39b6689b..cff5d074 100644 --- a/src/Generated/Models/InternalCreateThreadRequestToolResources.Serialization.cs +++ b/src/Generated/Models/InternalCreateThreadRequestToolResources.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadRequestToolResources : IJsonModel { - internal partial class InternalCreateThreadRequestToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateThreadRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateThreadRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateThreadRequestToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support reading '{format}' format."); } - internal static InternalCreateThreadRequestToolResources DeserializeInternalCreateThreadRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateThreadRequestToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalCreateThreadRequestToolResourcesCodeInterpreter codeInterpreter = default; - FileSearchToolResources fileSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateThreadRequestToolResources DeserializeInternalCreateThreadRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateThreadRequestToolResourcesCodeInterpreter codeInterpreter = default; + FileSearchToolResources fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("code_interpreter"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = InternalCreateThreadRequestToolResourcesCodeInterpreter.DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(property.Value, options); continue; } - if (property.NameEquals("file_search"u8)) + codeInterpreter = InternalCreateThreadRequestToolResourcesCodeInterpreter.DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = FileSearchToolResources.DeserializeFileSearchToolResources(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = FileSearchToolResources.DeserializeFileSearchToolResources(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateThreadRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateThreadRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); + } - InternalCreateThreadRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateThreadRequestToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateThreadRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateThreadRequestToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateThreadRequestToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateThreadRequestToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateThreadRequestToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateThreadRequestToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadRequestToolResources.cs b/src/Generated/Models/InternalCreateThreadRequestToolResources.cs index 08a68fce..11f2b651 100644 --- a/src/Generated/Models/InternalCreateThreadRequestToolResources.cs +++ b/src/Generated/Models/InternalCreateThreadRequestToolResources.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadRequestToolResources { - internal partial class InternalCreateThreadRequestToolResources + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateThreadRequestToolResources() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateThreadRequestToolResources() - { - } - - internal InternalCreateThreadRequestToolResources(InternalCreateThreadRequestToolResourcesCodeInterpreter codeInterpreter, FileSearchToolResources fileSearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalCreateThreadRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } - public FileSearchToolResources FileSearch { get; set; } + internal InternalCreateThreadRequestToolResources(InternalCreateThreadRequestToolResourcesCodeInterpreter codeInterpreter, FileSearchToolResources fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalCreateThreadRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } + public FileSearchToolResources FileSearch { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.Serialization.cs index 55825459..a449497f 100644 --- a/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadRequestToolResourcesCodeInterpreter : IJsonModel { - internal partial class InternalCreateThreadRequestToolResourcesCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateThreadRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateThreadRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalCreateThreadRequestToolResourcesCodeInterpreter DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateThreadRequestToolResourcesCodeInterpreter DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + fileIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateThreadRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateThreadRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalCreateThreadRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateThreadRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateThreadRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateThreadRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateThreadRequestToolResourcesCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.cs b/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.cs index df61d7ce..eb2418d7 100644 --- a/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.cs +++ b/src/Generated/Models/InternalCreateThreadRequestToolResourcesCodeInterpreter.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadRequestToolResourcesCodeInterpreter { - internal partial class InternalCreateThreadRequestToolResourcesCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateThreadRequestToolResourcesCodeInterpreter() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateThreadRequestToolResourcesCodeInterpreter() - { - FileIds = new ChangeTrackingList(); - } - - internal InternalCreateThreadRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + } - public IList FileIds { get; } + internal InternalCreateThreadRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList FileIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.Serialization.cs b/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.Serialization.cs index bc7fd659..45a40f6b 100644 --- a/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.Serialization.cs +++ b/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.Serialization.cs @@ -8,115 +8,114 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadRequestToolResourcesFileSearchBase : IJsonModel { - internal partial class InternalCreateThreadRequestToolResourcesFileSearchBase : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateThreadRequestToolResourcesFileSearchBase IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateThreadRequestToolResourcesFileSearchBase IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support reading '{format}' format."); } - internal static InternalCreateThreadRequestToolResourcesFileSearchBase DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateThreadRequestToolResourcesFileSearchBase(serializedAdditionalRawData); - } + internal static InternalCreateThreadRequestToolResourcesFileSearchBase DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalCreateThreadRequestToolResourcesFileSearchBase IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateThreadRequestToolResourcesFileSearchBase(serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateThreadRequestToolResourcesFileSearchBase FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalCreateThreadRequestToolResourcesFileSearchBase IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateThreadRequestToolResourcesFileSearchBase)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateThreadRequestToolResourcesFileSearchBase FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateThreadRequestToolResourcesFileSearchBase(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.cs b/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.cs index 4a84b73f..be4d3192 100644 --- a/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.cs +++ b/src/Generated/Models/InternalCreateThreadRequestToolResourcesFileSearchBase.cs @@ -5,18 +5,17 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalCreateThreadRequestToolResourcesFileSearchBase { - internal partial class InternalCreateThreadRequestToolResourcesFileSearchBase + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateThreadRequestToolResourcesFileSearchBase() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateThreadRequestToolResourcesFileSearchBase() - { - } + } - internal InternalCreateThreadRequestToolResourcesFileSearchBase(IDictionary serializedAdditionalRawData) - { - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalCreateThreadRequestToolResourcesFileSearchBase(IDictionary serializedAdditionalRawData) + { + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranscriptionRequestModel.cs b/src/Generated/Models/InternalCreateTranscriptionRequestModel.cs index a04004f2..d755b867 100644 --- a/src/Generated/Models/InternalCreateTranscriptionRequestModel.cs +++ b/src/Generated/Models/InternalCreateTranscriptionRequestModel.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal readonly partial struct InternalCreateTranscriptionRequestModel : IEquatable { - internal readonly partial struct InternalCreateTranscriptionRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateTranscriptionRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateTranscriptionRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string Whisper1Value = "whisper-1"; + private const string Whisper1Value = "whisper-1"; - public static InternalCreateTranscriptionRequestModel Whisper1 { get; } = new InternalCreateTranscriptionRequestModel(Whisper1Value); - public static bool operator ==(InternalCreateTranscriptionRequestModel left, InternalCreateTranscriptionRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateTranscriptionRequestModel left, InternalCreateTranscriptionRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateTranscriptionRequestModel(string value) => new InternalCreateTranscriptionRequestModel(value); + public static InternalCreateTranscriptionRequestModel Whisper1 { get; } = new InternalCreateTranscriptionRequestModel(Whisper1Value); + public static bool operator ==(InternalCreateTranscriptionRequestModel left, InternalCreateTranscriptionRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateTranscriptionRequestModel left, InternalCreateTranscriptionRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateTranscriptionRequestModel(string value) => new InternalCreateTranscriptionRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateTranscriptionRequestModel other && Equals(other); - public bool Equals(InternalCreateTranscriptionRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateTranscriptionRequestModel other && Equals(other); + public bool Equals(InternalCreateTranscriptionRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranscriptionRequestTimestampGranularity.cs b/src/Generated/Models/InternalCreateTranscriptionRequestTimestampGranularity.cs index 5a13a25c..c904b9b3 100644 --- a/src/Generated/Models/InternalCreateTranscriptionRequestTimestampGranularity.cs +++ b/src/Generated/Models/InternalCreateTranscriptionRequestTimestampGranularity.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal readonly partial struct InternalCreateTranscriptionRequestTimestampGranularity : IEquatable { - internal readonly partial struct InternalCreateTranscriptionRequestTimestampGranularity : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateTranscriptionRequestTimestampGranularity(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateTranscriptionRequestTimestampGranularity(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string WordValue = "word"; - private const string SegmentValue = "segment"; + private const string WordValue = "word"; + private const string SegmentValue = "segment"; - public static InternalCreateTranscriptionRequestTimestampGranularity Word { get; } = new InternalCreateTranscriptionRequestTimestampGranularity(WordValue); - public static InternalCreateTranscriptionRequestTimestampGranularity Segment { get; } = new InternalCreateTranscriptionRequestTimestampGranularity(SegmentValue); - public static bool operator ==(InternalCreateTranscriptionRequestTimestampGranularity left, InternalCreateTranscriptionRequestTimestampGranularity right) => left.Equals(right); - public static bool operator !=(InternalCreateTranscriptionRequestTimestampGranularity left, InternalCreateTranscriptionRequestTimestampGranularity right) => !left.Equals(right); - public static implicit operator InternalCreateTranscriptionRequestTimestampGranularity(string value) => new InternalCreateTranscriptionRequestTimestampGranularity(value); + public static InternalCreateTranscriptionRequestTimestampGranularity Word { get; } = new InternalCreateTranscriptionRequestTimestampGranularity(WordValue); + public static InternalCreateTranscriptionRequestTimestampGranularity Segment { get; } = new InternalCreateTranscriptionRequestTimestampGranularity(SegmentValue); + public static bool operator ==(InternalCreateTranscriptionRequestTimestampGranularity left, InternalCreateTranscriptionRequestTimestampGranularity right) => left.Equals(right); + public static bool operator !=(InternalCreateTranscriptionRequestTimestampGranularity left, InternalCreateTranscriptionRequestTimestampGranularity right) => !left.Equals(right); + public static implicit operator InternalCreateTranscriptionRequestTimestampGranularity(string value) => new InternalCreateTranscriptionRequestTimestampGranularity(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateTranscriptionRequestTimestampGranularity other && Equals(other); - public bool Equals(InternalCreateTranscriptionRequestTimestampGranularity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateTranscriptionRequestTimestampGranularity other && Equals(other); + public bool Equals(InternalCreateTranscriptionRequestTimestampGranularity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranscriptionResponseJson.Serialization.cs b/src/Generated/Models/InternalCreateTranscriptionResponseJson.Serialization.cs index a5e4863a..1d487f18 100644 --- a/src/Generated/Models/InternalCreateTranscriptionResponseJson.Serialization.cs +++ b/src/Generated/Models/InternalCreateTranscriptionResponseJson.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal partial class InternalCreateTranscriptionResponseJson : IJsonModel { - internal partial class InternalCreateTranscriptionResponseJson : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("text") != true) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support writing '{format}' format."); } - InternalCreateTranscriptionResponseJson IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("text") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateTranscriptionResponseJson(document.RootElement, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); } - - internal static InternalCreateTranscriptionResponseJson DeserializeInternalCreateTranscriptionResponseJson(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("text"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - text = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateTranscriptionResponseJson(text, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalCreateTranscriptionResponseJson IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support reading '{format}' format."); } - InternalCreateTranscriptionResponseJson IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateTranscriptionResponseJson(document.RootElement, options); + } + + internal static InternalCreateTranscriptionResponseJson DeserializeInternalCreateTranscriptionResponseJson(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateTranscriptionResponseJson(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support reading '{options.Format}' format."); + text = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateTranscriptionResponseJson(text, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateTranscriptionResponseJson FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateTranscriptionResponseJson(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support writing '{options.Format}' format."); } + } + + InternalCreateTranscriptionResponseJson IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateTranscriptionResponseJson(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateTranscriptionResponseJson)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateTranscriptionResponseJson FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateTranscriptionResponseJson(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranscriptionResponseJson.cs b/src/Generated/Models/InternalCreateTranscriptionResponseJson.cs index 19818f1d..f82ea07d 100644 --- a/src/Generated/Models/InternalCreateTranscriptionResponseJson.cs +++ b/src/Generated/Models/InternalCreateTranscriptionResponseJson.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal partial class InternalCreateTranscriptionResponseJson { - internal partial class InternalCreateTranscriptionResponseJson + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateTranscriptionResponseJson(string text) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateTranscriptionResponseJson(string text) - { - Argument.AssertNotNull(text, nameof(text)); - - Text = text; - } + Argument.AssertNotNull(text, nameof(text)); - internal InternalCreateTranscriptionResponseJson(string text, IDictionary serializedAdditionalRawData) - { - Text = text; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Text = text; + } - internal InternalCreateTranscriptionResponseJson() - { - } + internal InternalCreateTranscriptionResponseJson(string text, IDictionary serializedAdditionalRawData) + { + Text = text; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string Text { get; } + internal InternalCreateTranscriptionResponseJson() + { } -} + + public string Text { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranscriptionResponseVerboseJsonTask.cs b/src/Generated/Models/InternalCreateTranscriptionResponseVerboseJsonTask.cs index a94a2f56..2c9950f7 100644 --- a/src/Generated/Models/InternalCreateTranscriptionResponseVerboseJsonTask.cs +++ b/src/Generated/Models/InternalCreateTranscriptionResponseVerboseJsonTask.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal readonly partial struct InternalCreateTranscriptionResponseVerboseJsonTask : IEquatable { - internal readonly partial struct InternalCreateTranscriptionResponseVerboseJsonTask : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateTranscriptionResponseVerboseJsonTask(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateTranscriptionResponseVerboseJsonTask(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TranscribeValue = "transcribe"; + private const string TranscribeValue = "transcribe"; - public static InternalCreateTranscriptionResponseVerboseJsonTask Transcribe { get; } = new InternalCreateTranscriptionResponseVerboseJsonTask(TranscribeValue); - public static bool operator ==(InternalCreateTranscriptionResponseVerboseJsonTask left, InternalCreateTranscriptionResponseVerboseJsonTask right) => left.Equals(right); - public static bool operator !=(InternalCreateTranscriptionResponseVerboseJsonTask left, InternalCreateTranscriptionResponseVerboseJsonTask right) => !left.Equals(right); - public static implicit operator InternalCreateTranscriptionResponseVerboseJsonTask(string value) => new InternalCreateTranscriptionResponseVerboseJsonTask(value); + public static InternalCreateTranscriptionResponseVerboseJsonTask Transcribe { get; } = new InternalCreateTranscriptionResponseVerboseJsonTask(TranscribeValue); + public static bool operator ==(InternalCreateTranscriptionResponseVerboseJsonTask left, InternalCreateTranscriptionResponseVerboseJsonTask right) => left.Equals(right); + public static bool operator !=(InternalCreateTranscriptionResponseVerboseJsonTask left, InternalCreateTranscriptionResponseVerboseJsonTask right) => !left.Equals(right); + public static implicit operator InternalCreateTranscriptionResponseVerboseJsonTask(string value) => new InternalCreateTranscriptionResponseVerboseJsonTask(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateTranscriptionResponseVerboseJsonTask other && Equals(other); - public bool Equals(InternalCreateTranscriptionResponseVerboseJsonTask other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateTranscriptionResponseVerboseJsonTask other && Equals(other); + public bool Equals(InternalCreateTranscriptionResponseVerboseJsonTask other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranslationRequestModel.cs b/src/Generated/Models/InternalCreateTranslationRequestModel.cs index 67effb4f..7313bb4e 100644 --- a/src/Generated/Models/InternalCreateTranslationRequestModel.cs +++ b/src/Generated/Models/InternalCreateTranslationRequestModel.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal readonly partial struct InternalCreateTranslationRequestModel : IEquatable { - internal readonly partial struct InternalCreateTranslationRequestModel : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateTranslationRequestModel(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateTranslationRequestModel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string Whisper1Value = "whisper-1"; + private const string Whisper1Value = "whisper-1"; - public static InternalCreateTranslationRequestModel Whisper1 { get; } = new InternalCreateTranslationRequestModel(Whisper1Value); - public static bool operator ==(InternalCreateTranslationRequestModel left, InternalCreateTranslationRequestModel right) => left.Equals(right); - public static bool operator !=(InternalCreateTranslationRequestModel left, InternalCreateTranslationRequestModel right) => !left.Equals(right); - public static implicit operator InternalCreateTranslationRequestModel(string value) => new InternalCreateTranslationRequestModel(value); + public static InternalCreateTranslationRequestModel Whisper1 { get; } = new InternalCreateTranslationRequestModel(Whisper1Value); + public static bool operator ==(InternalCreateTranslationRequestModel left, InternalCreateTranslationRequestModel right) => left.Equals(right); + public static bool operator !=(InternalCreateTranslationRequestModel left, InternalCreateTranslationRequestModel right) => !left.Equals(right); + public static implicit operator InternalCreateTranslationRequestModel(string value) => new InternalCreateTranslationRequestModel(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateTranslationRequestModel other && Equals(other); - public bool Equals(InternalCreateTranslationRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateTranslationRequestModel other && Equals(other); + public bool Equals(InternalCreateTranslationRequestModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranslationResponseJson.Serialization.cs b/src/Generated/Models/InternalCreateTranslationResponseJson.Serialization.cs index d0d1fcd3..713df63d 100644 --- a/src/Generated/Models/InternalCreateTranslationResponseJson.Serialization.cs +++ b/src/Generated/Models/InternalCreateTranslationResponseJson.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal partial class InternalCreateTranslationResponseJson : IJsonModel { - internal partial class InternalCreateTranslationResponseJson : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("text") != true) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support writing '{format}' format."); } - InternalCreateTranslationResponseJson IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("text") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateTranslationResponseJson(document.RootElement, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); } - - internal static InternalCreateTranslationResponseJson DeserializeInternalCreateTranslationResponseJson(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("text"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - text = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateTranslationResponseJson(text, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalCreateTranslationResponseJson IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support reading '{format}' format."); } - InternalCreateTranslationResponseJson IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateTranslationResponseJson(document.RootElement, options); + } + + internal static InternalCreateTranslationResponseJson DeserializeInternalCreateTranslationResponseJson(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateTranslationResponseJson(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support reading '{options.Format}' format."); + text = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateTranslationResponseJson(text, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateTranslationResponseJson FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateTranslationResponseJson(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support writing '{options.Format}' format."); } + } + + InternalCreateTranslationResponseJson IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateTranslationResponseJson(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateTranslationResponseJson)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateTranslationResponseJson FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateTranslationResponseJson(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranslationResponseJson.cs b/src/Generated/Models/InternalCreateTranslationResponseJson.cs index e6e9dae1..7e03bc5f 100644 --- a/src/Generated/Models/InternalCreateTranslationResponseJson.cs +++ b/src/Generated/Models/InternalCreateTranslationResponseJson.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal partial class InternalCreateTranslationResponseJson { - internal partial class InternalCreateTranslationResponseJson + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalCreateTranslationResponseJson(string text) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalCreateTranslationResponseJson(string text) - { - Argument.AssertNotNull(text, nameof(text)); - - Text = text; - } + Argument.AssertNotNull(text, nameof(text)); - internal InternalCreateTranslationResponseJson(string text, IDictionary serializedAdditionalRawData) - { - Text = text; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Text = text; + } - internal InternalCreateTranslationResponseJson() - { - } + internal InternalCreateTranslationResponseJson(string text, IDictionary serializedAdditionalRawData) + { + Text = text; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string Text { get; } + internal InternalCreateTranslationResponseJson() + { } -} + + public string Text { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateTranslationResponseVerboseJsonTask.cs b/src/Generated/Models/InternalCreateTranslationResponseVerboseJsonTask.cs index 08926128..24057ac4 100644 --- a/src/Generated/Models/InternalCreateTranslationResponseVerboseJsonTask.cs +++ b/src/Generated/Models/InternalCreateTranslationResponseVerboseJsonTask.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +internal readonly partial struct InternalCreateTranslationResponseVerboseJsonTask : IEquatable { - internal readonly partial struct InternalCreateTranslationResponseVerboseJsonTask : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalCreateTranslationResponseVerboseJsonTask(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalCreateTranslationResponseVerboseJsonTask(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TranslateValue = "translate"; + private const string TranslateValue = "translate"; - public static InternalCreateTranslationResponseVerboseJsonTask Translate { get; } = new InternalCreateTranslationResponseVerboseJsonTask(TranslateValue); - public static bool operator ==(InternalCreateTranslationResponseVerboseJsonTask left, InternalCreateTranslationResponseVerboseJsonTask right) => left.Equals(right); - public static bool operator !=(InternalCreateTranslationResponseVerboseJsonTask left, InternalCreateTranslationResponseVerboseJsonTask right) => !left.Equals(right); - public static implicit operator InternalCreateTranslationResponseVerboseJsonTask(string value) => new InternalCreateTranslationResponseVerboseJsonTask(value); + public static InternalCreateTranslationResponseVerboseJsonTask Translate { get; } = new InternalCreateTranslationResponseVerboseJsonTask(TranslateValue); + public static bool operator ==(InternalCreateTranslationResponseVerboseJsonTask left, InternalCreateTranslationResponseVerboseJsonTask right) => left.Equals(right); + public static bool operator !=(InternalCreateTranslationResponseVerboseJsonTask left, InternalCreateTranslationResponseVerboseJsonTask right) => !left.Equals(right); + public static implicit operator InternalCreateTranslationResponseVerboseJsonTask(string value) => new InternalCreateTranslationResponseVerboseJsonTask(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateTranslationResponseVerboseJsonTask other && Equals(other); - public bool Equals(InternalCreateTranslationResponseVerboseJsonTask other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateTranslationResponseVerboseJsonTask other && Equals(other); + public bool Equals(InternalCreateTranslationResponseVerboseJsonTask other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateUploadRequest.Serialization.cs b/src/Generated/Models/InternalCreateUploadRequest.Serialization.cs index e2ed769b..73ddbf21 100644 --- a/src/Generated/Models/InternalCreateUploadRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateUploadRequest.Serialization.cs @@ -8,159 +8,158 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalCreateUploadRequest : IJsonModel { - internal partial class InternalCreateUploadRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("filename") != true) - { - writer.WritePropertyName("filename"u8); - writer.WriteStringValue(Filename); - } - if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) - { - writer.WritePropertyName("purpose"u8); - writer.WriteStringValue(Purpose.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) - { - writer.WritePropertyName("bytes"u8); - writer.WriteNumberValue(Bytes); - } - if (SerializedAdditionalRawData?.ContainsKey("mime_type") != true) - { - writer.WritePropertyName("mime_type"u8); - writer.WriteStringValue(MimeType); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("filename") != true) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) + { + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + { + writer.WritePropertyName("bytes"u8); + writer.WriteNumberValue(Bytes); + } + if (SerializedAdditionalRawData?.ContainsKey("mime_type") != true) + { + writer.WritePropertyName("mime_type"u8); + writer.WriteStringValue(MimeType); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateUploadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateUploadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateUploadRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support reading '{format}' format."); } - internal static InternalCreateUploadRequest DeserializeInternalCreateUploadRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateUploadRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalCreateUploadRequest DeserializeInternalCreateUploadRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string filename = default; + InternalCreateUploadRequestPurpose purpose = default; + int bytes = default; + string mimeType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filename"u8)) { - return null; + filename = property.Value.GetString(); + continue; } - string filename = default; - InternalCreateUploadRequestPurpose purpose = default; - int bytes = default; - string mimeType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("purpose"u8)) { - if (property.NameEquals("filename"u8)) - { - filename = property.Value.GetString(); - continue; - } - if (property.NameEquals("purpose"u8)) - { - purpose = new InternalCreateUploadRequestPurpose(property.Value.GetString()); - continue; - } - if (property.NameEquals("bytes"u8)) - { - bytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("mime_type"u8)) - { - mimeType = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + purpose = new InternalCreateUploadRequestPurpose(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateUploadRequest(filename, purpose, bytes, mimeType, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("bytes"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support writing '{options.Format}' format."); + bytes = property.Value.GetInt32(); + continue; } - } - - InternalCreateUploadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("mime_type"u8)) + { + mimeType = property.Value.GetString(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateUploadRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateUploadRequest(filename, purpose, bytes, mimeType, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateUploadRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateUploadRequest(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support writing '{options.Format}' format."); } + } + + InternalCreateUploadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateUploadRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateUploadRequest)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateUploadRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateUploadRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateUploadRequest.cs b/src/Generated/Models/InternalCreateUploadRequest.cs index f580307a..db4727ea 100644 --- a/src/Generated/Models/InternalCreateUploadRequest.cs +++ b/src/Generated/Models/InternalCreateUploadRequest.cs @@ -5,38 +5,37 @@ using System; using System.Collections.Generic; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalCreateUploadRequest { - internal partial class InternalCreateUploadRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateUploadRequest(string filename, InternalCreateUploadRequestPurpose purpose, int bytes, string mimeType) + { + Argument.AssertNotNull(filename, nameof(filename)); + Argument.AssertNotNull(mimeType, nameof(mimeType)); + + Filename = filename; + Purpose = purpose; + Bytes = bytes; + MimeType = mimeType; + } + + internal InternalCreateUploadRequest(string filename, InternalCreateUploadRequestPurpose purpose, int bytes, string mimeType, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateUploadRequest(string filename, InternalCreateUploadRequestPurpose purpose, int bytes, string mimeType) - { - Argument.AssertNotNull(filename, nameof(filename)); - Argument.AssertNotNull(mimeType, nameof(mimeType)); - - Filename = filename; - Purpose = purpose; - Bytes = bytes; - MimeType = mimeType; - } - - internal InternalCreateUploadRequest(string filename, InternalCreateUploadRequestPurpose purpose, int bytes, string mimeType, IDictionary serializedAdditionalRawData) - { - Filename = filename; - Purpose = purpose; - Bytes = bytes; - MimeType = mimeType; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateUploadRequest() - { - } - - public string Filename { get; } - public InternalCreateUploadRequestPurpose Purpose { get; } - public int Bytes { get; } - public string MimeType { get; } + Filename = filename; + Purpose = purpose; + Bytes = bytes; + MimeType = mimeType; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateUploadRequest() + { + } + + public string Filename { get; } + public InternalCreateUploadRequestPurpose Purpose { get; } + public int Bytes { get; } + public string MimeType { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateUploadRequestPurpose.cs b/src/Generated/Models/InternalCreateUploadRequestPurpose.cs index 6b76958f..b9f60089 100644 --- a/src/Generated/Models/InternalCreateUploadRequestPurpose.cs +++ b/src/Generated/Models/InternalCreateUploadRequestPurpose.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal readonly partial struct InternalCreateUploadRequestPurpose : IEquatable { - internal readonly partial struct InternalCreateUploadRequestPurpose : IEquatable + private readonly string _value; + + public InternalCreateUploadRequestPurpose(string value) { - private readonly string _value; - - public InternalCreateUploadRequestPurpose(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AssistantsValue = "assistants"; - private const string BatchValue = "batch"; - private const string FineTuneValue = "fine-tune"; - private const string VisionValue = "vision"; - - public static InternalCreateUploadRequestPurpose Assistants { get; } = new InternalCreateUploadRequestPurpose(AssistantsValue); - public static InternalCreateUploadRequestPurpose Batch { get; } = new InternalCreateUploadRequestPurpose(BatchValue); - public static InternalCreateUploadRequestPurpose FineTune { get; } = new InternalCreateUploadRequestPurpose(FineTuneValue); - public static InternalCreateUploadRequestPurpose Vision { get; } = new InternalCreateUploadRequestPurpose(VisionValue); - public static bool operator ==(InternalCreateUploadRequestPurpose left, InternalCreateUploadRequestPurpose right) => left.Equals(right); - public static bool operator !=(InternalCreateUploadRequestPurpose left, InternalCreateUploadRequestPurpose right) => !left.Equals(right); - public static implicit operator InternalCreateUploadRequestPurpose(string value) => new InternalCreateUploadRequestPurpose(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalCreateUploadRequestPurpose other && Equals(other); - public bool Equals(InternalCreateUploadRequestPurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AssistantsValue = "assistants"; + private const string BatchValue = "batch"; + private const string FineTuneValue = "fine-tune"; + private const string VisionValue = "vision"; + + public static InternalCreateUploadRequestPurpose Assistants { get; } = new InternalCreateUploadRequestPurpose(AssistantsValue); + public static InternalCreateUploadRequestPurpose Batch { get; } = new InternalCreateUploadRequestPurpose(BatchValue); + public static InternalCreateUploadRequestPurpose FineTune { get; } = new InternalCreateUploadRequestPurpose(FineTuneValue); + public static InternalCreateUploadRequestPurpose Vision { get; } = new InternalCreateUploadRequestPurpose(VisionValue); + public static bool operator ==(InternalCreateUploadRequestPurpose left, InternalCreateUploadRequestPurpose right) => left.Equals(right); + public static bool operator !=(InternalCreateUploadRequestPurpose left, InternalCreateUploadRequestPurpose right) => !left.Equals(right); + public static implicit operator InternalCreateUploadRequestPurpose(string value) => new InternalCreateUploadRequestPurpose(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateUploadRequestPurpose other && Equals(other); + public bool Equals(InternalCreateUploadRequestPurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs index 90585d41..be9fa0d2 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.Serialization.cs @@ -8,158 +8,157 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalCreateVectorStoreFileBatchRequest : IJsonModel { - internal partial class InternalCreateVectorStoreFileBatchRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) - { - writer.WritePropertyName("chunking_strategy"u8); + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(ChunkingStrategy); #else - using (JsonDocument document = JsonDocument.Parse(ChunkingStrategy)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(ChunkingStrategy)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateVectorStoreFileBatchRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateVectorStoreFileBatchRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateVectorStoreFileBatchRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support reading '{format}' format."); } - internal static InternalCreateVectorStoreFileBatchRequest DeserializeInternalCreateVectorStoreFileBatchRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateVectorStoreFileBatchRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - BinaryData chunkingStrategy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalCreateVectorStoreFileBatchRequest DeserializeInternalCreateVectorStoreFileBatchRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + BinaryData chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; - continue; + array.Add(item.GetString()); } - if (property.NameEquals("chunking_strategy"u8)) + fileIds = array; + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + chunkingStrategy = BinaryData.FromString(property.Value.GetRawText()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateVectorStoreFileBatchRequest(fileIds, chunkingStrategy, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateVectorStoreFileBatchRequest(fileIds, chunkingStrategy, serializedAdditionalRawData); + } - InternalCreateVectorStoreFileBatchRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateVectorStoreFileBatchRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateVectorStoreFileBatchRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateVectorStoreFileBatchRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateVectorStoreFileBatchRequest(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateVectorStoreFileBatchRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileBatchRequest)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateVectorStoreFileBatchRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateVectorStoreFileBatchRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs index 3064e350..95f99438 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileBatchRequest.cs @@ -6,30 +6,29 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalCreateVectorStoreFileBatchRequest { - internal partial class InternalCreateVectorStoreFileBatchRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateVectorStoreFileBatchRequest(IEnumerable fileIds) + { + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + FileIds = fileIds.ToList(); + } + + internal InternalCreateVectorStoreFileBatchRequest(IList fileIds, BinaryData chunkingStrategy, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateVectorStoreFileBatchRequest(IEnumerable fileIds) - { - Argument.AssertNotNull(fileIds, nameof(fileIds)); - - FileIds = fileIds.ToList(); - } - - internal InternalCreateVectorStoreFileBatchRequest(IList fileIds, BinaryData chunkingStrategy, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - ChunkingStrategy = chunkingStrategy; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateVectorStoreFileBatchRequest() - { - } - - public IList FileIds { get; } - public BinaryData ChunkingStrategy { get; set; } + FileIds = fileIds; + ChunkingStrategy = chunkingStrategy; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateVectorStoreFileBatchRequest() + { + } + + public IList FileIds { get; } + public BinaryData ChunkingStrategy { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs b/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs index 4e124f18..daf6b44c 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileRequest.Serialization.cs @@ -8,141 +8,140 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalCreateVectorStoreFileRequest : IJsonModel { - internal partial class InternalCreateVectorStoreFileRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) - { - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalCreateVectorStoreFileRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalCreateVectorStoreFileRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalCreateVectorStoreFileRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support reading '{format}' format."); } - internal static InternalCreateVectorStoreFileRequest DeserializeInternalCreateVectorStoreFileRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateVectorStoreFileRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalCreateVectorStoreFileRequest DeserializeInternalCreateVectorStoreFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + FileChunkingStrategy chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - return null; + fileId = property.Value.GetString(); + continue; } - string fileId = default; - FileChunkingStrategy chunkingStrategy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("chunking_strategy"u8)) { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("chunking_strategy"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalCreateVectorStoreFileRequest(fileId, chunkingStrategy, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalCreateVectorStoreFileRequest(fileId, chunkingStrategy, serializedAdditionalRawData); + } - InternalCreateVectorStoreFileRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalCreateVectorStoreFileRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalCreateVectorStoreFileRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalCreateVectorStoreFileRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalCreateVectorStoreFileRequest(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalCreateVectorStoreFileRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateVectorStoreFileRequest)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalCreateVectorStoreFileRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalCreateVectorStoreFileRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs b/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs index 4224f5fc..fb93306a 100644 --- a/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs +++ b/src/Generated/Models/InternalCreateVectorStoreFileRequest.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalCreateVectorStoreFileRequest { - internal partial class InternalCreateVectorStoreFileRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalCreateVectorStoreFileRequest(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + internal InternalCreateVectorStoreFileRequest(string fileId, FileChunkingStrategy chunkingStrategy, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalCreateVectorStoreFileRequest(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } - - internal InternalCreateVectorStoreFileRequest(string fileId, FileChunkingStrategy chunkingStrategy, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - ChunkingStrategy = chunkingStrategy; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalCreateVectorStoreFileRequest() - { - } - - public string FileId { get; } + FileId = fileId; + ChunkingStrategy = chunkingStrategy; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalCreateVectorStoreFileRequest() + { + } + + public string FileId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalDeleteAssistantResponseObject.cs b/src/Generated/Models/InternalDeleteAssistantResponseObject.cs index 1ee13904..d7ff93c5 100644 --- a/src/Generated/Models/InternalDeleteAssistantResponseObject.cs +++ b/src/Generated/Models/InternalDeleteAssistantResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalDeleteAssistantResponseObject : IEquatable { - internal readonly partial struct InternalDeleteAssistantResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalDeleteAssistantResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalDeleteAssistantResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AssistantDeletedValue = "assistant.deleted"; + private const string AssistantDeletedValue = "assistant.deleted"; - public static InternalDeleteAssistantResponseObject AssistantDeleted { get; } = new InternalDeleteAssistantResponseObject(AssistantDeletedValue); - public static bool operator ==(InternalDeleteAssistantResponseObject left, InternalDeleteAssistantResponseObject right) => left.Equals(right); - public static bool operator !=(InternalDeleteAssistantResponseObject left, InternalDeleteAssistantResponseObject right) => !left.Equals(right); - public static implicit operator InternalDeleteAssistantResponseObject(string value) => new InternalDeleteAssistantResponseObject(value); + public static InternalDeleteAssistantResponseObject AssistantDeleted { get; } = new InternalDeleteAssistantResponseObject(AssistantDeletedValue); + public static bool operator ==(InternalDeleteAssistantResponseObject left, InternalDeleteAssistantResponseObject right) => left.Equals(right); + public static bool operator !=(InternalDeleteAssistantResponseObject left, InternalDeleteAssistantResponseObject right) => !left.Equals(right); + public static implicit operator InternalDeleteAssistantResponseObject(string value) => new InternalDeleteAssistantResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalDeleteAssistantResponseObject other && Equals(other); - public bool Equals(InternalDeleteAssistantResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalDeleteAssistantResponseObject other && Equals(other); + public bool Equals(InternalDeleteAssistantResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalDeleteFileResponseObject.cs b/src/Generated/Models/InternalDeleteFileResponseObject.cs index f6fbfc91..72c87a6d 100644 --- a/src/Generated/Models/InternalDeleteFileResponseObject.cs +++ b/src/Generated/Models/InternalDeleteFileResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal readonly partial struct InternalDeleteFileResponseObject : IEquatable { - internal readonly partial struct InternalDeleteFileResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalDeleteFileResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalDeleteFileResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FileValue = "file"; + private const string FileValue = "file"; - public static InternalDeleteFileResponseObject File { get; } = new InternalDeleteFileResponseObject(FileValue); - public static bool operator ==(InternalDeleteFileResponseObject left, InternalDeleteFileResponseObject right) => left.Equals(right); - public static bool operator !=(InternalDeleteFileResponseObject left, InternalDeleteFileResponseObject right) => !left.Equals(right); - public static implicit operator InternalDeleteFileResponseObject(string value) => new InternalDeleteFileResponseObject(value); + public static InternalDeleteFileResponseObject File { get; } = new InternalDeleteFileResponseObject(FileValue); + public static bool operator ==(InternalDeleteFileResponseObject left, InternalDeleteFileResponseObject right) => left.Equals(right); + public static bool operator !=(InternalDeleteFileResponseObject left, InternalDeleteFileResponseObject right) => !left.Equals(right); + public static implicit operator InternalDeleteFileResponseObject(string value) => new InternalDeleteFileResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalDeleteFileResponseObject other && Equals(other); - public bool Equals(InternalDeleteFileResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalDeleteFileResponseObject other && Equals(other); + public bool Equals(InternalDeleteFileResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalDeleteMessageResponseObject.cs b/src/Generated/Models/InternalDeleteMessageResponseObject.cs index 772ffbcb..4ce30d4f 100644 --- a/src/Generated/Models/InternalDeleteMessageResponseObject.cs +++ b/src/Generated/Models/InternalDeleteMessageResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalDeleteMessageResponseObject : IEquatable { - internal readonly partial struct InternalDeleteMessageResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalDeleteMessageResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalDeleteMessageResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadMessageDeletedValue = "thread.message.deleted"; + private const string ThreadMessageDeletedValue = "thread.message.deleted"; - public static InternalDeleteMessageResponseObject ThreadMessageDeleted { get; } = new InternalDeleteMessageResponseObject(ThreadMessageDeletedValue); - public static bool operator ==(InternalDeleteMessageResponseObject left, InternalDeleteMessageResponseObject right) => left.Equals(right); - public static bool operator !=(InternalDeleteMessageResponseObject left, InternalDeleteMessageResponseObject right) => !left.Equals(right); - public static implicit operator InternalDeleteMessageResponseObject(string value) => new InternalDeleteMessageResponseObject(value); + public static InternalDeleteMessageResponseObject ThreadMessageDeleted { get; } = new InternalDeleteMessageResponseObject(ThreadMessageDeletedValue); + public static bool operator ==(InternalDeleteMessageResponseObject left, InternalDeleteMessageResponseObject right) => left.Equals(right); + public static bool operator !=(InternalDeleteMessageResponseObject left, InternalDeleteMessageResponseObject right) => !left.Equals(right); + public static implicit operator InternalDeleteMessageResponseObject(string value) => new InternalDeleteMessageResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalDeleteMessageResponseObject other && Equals(other); - public bool Equals(InternalDeleteMessageResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalDeleteMessageResponseObject other && Equals(other); + public bool Equals(InternalDeleteMessageResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalDeleteModelResponseObject.cs b/src/Generated/Models/InternalDeleteModelResponseObject.cs index 967d11d7..e330b470 100644 --- a/src/Generated/Models/InternalDeleteModelResponseObject.cs +++ b/src/Generated/Models/InternalDeleteModelResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Models +namespace OpenAI.Models; + +internal readonly partial struct InternalDeleteModelResponseObject : IEquatable { - internal readonly partial struct InternalDeleteModelResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalDeleteModelResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalDeleteModelResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ModelValue = "model"; + private const string ModelValue = "model"; - public static InternalDeleteModelResponseObject Model { get; } = new InternalDeleteModelResponseObject(ModelValue); - public static bool operator ==(InternalDeleteModelResponseObject left, InternalDeleteModelResponseObject right) => left.Equals(right); - public static bool operator !=(InternalDeleteModelResponseObject left, InternalDeleteModelResponseObject right) => !left.Equals(right); - public static implicit operator InternalDeleteModelResponseObject(string value) => new InternalDeleteModelResponseObject(value); + public static InternalDeleteModelResponseObject Model { get; } = new InternalDeleteModelResponseObject(ModelValue); + public static bool operator ==(InternalDeleteModelResponseObject left, InternalDeleteModelResponseObject right) => left.Equals(right); + public static bool operator !=(InternalDeleteModelResponseObject left, InternalDeleteModelResponseObject right) => !left.Equals(right); + public static implicit operator InternalDeleteModelResponseObject(string value) => new InternalDeleteModelResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalDeleteModelResponseObject other && Equals(other); - public bool Equals(InternalDeleteModelResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalDeleteModelResponseObject other && Equals(other); + public bool Equals(InternalDeleteModelResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalDeleteThreadResponseObject.cs b/src/Generated/Models/InternalDeleteThreadResponseObject.cs index bc843faa..e8e4a6a4 100644 --- a/src/Generated/Models/InternalDeleteThreadResponseObject.cs +++ b/src/Generated/Models/InternalDeleteThreadResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalDeleteThreadResponseObject : IEquatable { - internal readonly partial struct InternalDeleteThreadResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalDeleteThreadResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalDeleteThreadResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadDeletedValue = "thread.deleted"; + private const string ThreadDeletedValue = "thread.deleted"; - public static InternalDeleteThreadResponseObject ThreadDeleted { get; } = new InternalDeleteThreadResponseObject(ThreadDeletedValue); - public static bool operator ==(InternalDeleteThreadResponseObject left, InternalDeleteThreadResponseObject right) => left.Equals(right); - public static bool operator !=(InternalDeleteThreadResponseObject left, InternalDeleteThreadResponseObject right) => !left.Equals(right); - public static implicit operator InternalDeleteThreadResponseObject(string value) => new InternalDeleteThreadResponseObject(value); + public static InternalDeleteThreadResponseObject ThreadDeleted { get; } = new InternalDeleteThreadResponseObject(ThreadDeletedValue); + public static bool operator ==(InternalDeleteThreadResponseObject left, InternalDeleteThreadResponseObject right) => left.Equals(right); + public static bool operator !=(InternalDeleteThreadResponseObject left, InternalDeleteThreadResponseObject right) => !left.Equals(right); + public static implicit operator InternalDeleteThreadResponseObject(string value) => new InternalDeleteThreadResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalDeleteThreadResponseObject other && Equals(other); - public bool Equals(InternalDeleteThreadResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalDeleteThreadResponseObject other && Equals(other); + public bool Equals(InternalDeleteThreadResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalDeleteVectorStoreFileResponseObject.cs b/src/Generated/Models/InternalDeleteVectorStoreFileResponseObject.cs index 6716460a..c427ca5b 100644 --- a/src/Generated/Models/InternalDeleteVectorStoreFileResponseObject.cs +++ b/src/Generated/Models/InternalDeleteVectorStoreFileResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalDeleteVectorStoreFileResponseObject : IEquatable { - internal readonly partial struct InternalDeleteVectorStoreFileResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalDeleteVectorStoreFileResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalDeleteVectorStoreFileResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string VectorStoreFileDeletedValue = "vector_store.file.deleted"; + private const string VectorStoreFileDeletedValue = "vector_store.file.deleted"; - public static InternalDeleteVectorStoreFileResponseObject VectorStoreFileDeleted { get; } = new InternalDeleteVectorStoreFileResponseObject(VectorStoreFileDeletedValue); - public static bool operator ==(InternalDeleteVectorStoreFileResponseObject left, InternalDeleteVectorStoreFileResponseObject right) => left.Equals(right); - public static bool operator !=(InternalDeleteVectorStoreFileResponseObject left, InternalDeleteVectorStoreFileResponseObject right) => !left.Equals(right); - public static implicit operator InternalDeleteVectorStoreFileResponseObject(string value) => new InternalDeleteVectorStoreFileResponseObject(value); + public static InternalDeleteVectorStoreFileResponseObject VectorStoreFileDeleted { get; } = new InternalDeleteVectorStoreFileResponseObject(VectorStoreFileDeletedValue); + public static bool operator ==(InternalDeleteVectorStoreFileResponseObject left, InternalDeleteVectorStoreFileResponseObject right) => left.Equals(right); + public static bool operator !=(InternalDeleteVectorStoreFileResponseObject left, InternalDeleteVectorStoreFileResponseObject right) => !left.Equals(right); + public static implicit operator InternalDeleteVectorStoreFileResponseObject(string value) => new InternalDeleteVectorStoreFileResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalDeleteVectorStoreFileResponseObject other && Equals(other); - public bool Equals(InternalDeleteVectorStoreFileResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalDeleteVectorStoreFileResponseObject other && Equals(other); + public bool Equals(InternalDeleteVectorStoreFileResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalDeleteVectorStoreResponseObject.cs b/src/Generated/Models/InternalDeleteVectorStoreResponseObject.cs index c13ec4b2..f9bdfb38 100644 --- a/src/Generated/Models/InternalDeleteVectorStoreResponseObject.cs +++ b/src/Generated/Models/InternalDeleteVectorStoreResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalDeleteVectorStoreResponseObject : IEquatable { - internal readonly partial struct InternalDeleteVectorStoreResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalDeleteVectorStoreResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalDeleteVectorStoreResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string VectorStoreDeletedValue = "vector_store.deleted"; + private const string VectorStoreDeletedValue = "vector_store.deleted"; - public static InternalDeleteVectorStoreResponseObject VectorStoreDeleted { get; } = new InternalDeleteVectorStoreResponseObject(VectorStoreDeletedValue); - public static bool operator ==(InternalDeleteVectorStoreResponseObject left, InternalDeleteVectorStoreResponseObject right) => left.Equals(right); - public static bool operator !=(InternalDeleteVectorStoreResponseObject left, InternalDeleteVectorStoreResponseObject right) => !left.Equals(right); - public static implicit operator InternalDeleteVectorStoreResponseObject(string value) => new InternalDeleteVectorStoreResponseObject(value); + public static InternalDeleteVectorStoreResponseObject VectorStoreDeleted { get; } = new InternalDeleteVectorStoreResponseObject(VectorStoreDeletedValue); + public static bool operator ==(InternalDeleteVectorStoreResponseObject left, InternalDeleteVectorStoreResponseObject right) => left.Equals(right); + public static bool operator !=(InternalDeleteVectorStoreResponseObject left, InternalDeleteVectorStoreResponseObject right) => !left.Equals(right); + public static implicit operator InternalDeleteVectorStoreResponseObject(string value) => new InternalDeleteVectorStoreResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalDeleteVectorStoreResponseObject other && Equals(other); - public bool Equals(InternalDeleteVectorStoreResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalDeleteVectorStoreResponseObject other && Equals(other); + public bool Equals(InternalDeleteVectorStoreResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalEmbeddingObject.cs b/src/Generated/Models/InternalEmbeddingObject.cs index 5a0c0e4d..25f4b6ff 100644 --- a/src/Generated/Models/InternalEmbeddingObject.cs +++ b/src/Generated/Models/InternalEmbeddingObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Embeddings +namespace OpenAI.Embeddings; + +internal readonly partial struct InternalEmbeddingObject : IEquatable { - internal readonly partial struct InternalEmbeddingObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalEmbeddingObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalEmbeddingObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string EmbeddingValue = "embedding"; + private const string EmbeddingValue = "embedding"; - public static InternalEmbeddingObject Embedding { get; } = new InternalEmbeddingObject(EmbeddingValue); - public static bool operator ==(InternalEmbeddingObject left, InternalEmbeddingObject right) => left.Equals(right); - public static bool operator !=(InternalEmbeddingObject left, InternalEmbeddingObject right) => !left.Equals(right); - public static implicit operator InternalEmbeddingObject(string value) => new InternalEmbeddingObject(value); + public static InternalEmbeddingObject Embedding { get; } = new InternalEmbeddingObject(EmbeddingValue); + public static bool operator ==(InternalEmbeddingObject left, InternalEmbeddingObject right) => left.Equals(right); + public static bool operator !=(InternalEmbeddingObject left, InternalEmbeddingObject right) => !left.Equals(right); + public static implicit operator InternalEmbeddingObject(string value) => new InternalEmbeddingObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalEmbeddingObject other && Equals(other); - public bool Equals(InternalEmbeddingObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalEmbeddingObject other && Equals(other); + public bool Equals(InternalEmbeddingObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFileChunkingStrategyRequestParam.Serialization.cs b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.Serialization.cs index 4a61d2d1..eb7743d4 100644 --- a/src/Generated/Models/InternalFileChunkingStrategyRequestParam.Serialization.cs +++ b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.Serialization.cs @@ -7,118 +7,117 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +[PersistableModelProxy(typeof(InternalUnknownFileChunkingStrategyRequestParamProxy))] +internal partial class InternalFileChunkingStrategyRequestParam : IJsonModel { - [PersistableModelProxy(typeof(InternalUnknownFileChunkingStrategyRequestParamProxy))] - internal partial class InternalFileChunkingStrategyRequestParam : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFileChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFileChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{format}' format."); } - internal static InternalFileChunkingStrategyRequestParam DeserializeInternalFileChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "auto": return InternalAutoChunkingStrategyRequestParam.DeserializeInternalAutoChunkingStrategyRequestParam(element, options); - case "static": return InternalStaticChunkingStrategyRequestParam.DeserializeInternalStaticChunkingStrategyRequestParam(element, options); - } - } - return InternalUnknownFileChunkingStrategyRequestParamProxy.DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(element, options); - } + internal static InternalFileChunkingStrategyRequestParam DeserializeInternalFileChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalFileChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); + case "auto": return InternalAutoChunkingStrategyRequestParam.DeserializeInternalAutoChunkingStrategyRequestParam(element, options); + case "static": return InternalStaticChunkingStrategyRequestParam.DeserializeInternalStaticChunkingStrategyRequestParam(element, options); } } + return InternalUnknownFileChunkingStrategyRequestParamProxy.DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFileChunkingStrategyRequestParam FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalFileChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFileChunkingStrategyRequestParam FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFileChunkingStrategyRequestParam.cs b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.cs index 275a076e..f0188bc7 100644 --- a/src/Generated/Models/InternalFileChunkingStrategyRequestParam.cs +++ b/src/Generated/Models/InternalFileChunkingStrategyRequestParam.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal abstract partial class InternalFileChunkingStrategyRequestParam { - internal abstract partial class InternalFileChunkingStrategyRequestParam + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalFileChunkingStrategyRequestParam() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalFileChunkingStrategyRequestParam() - { - } - - internal InternalFileChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalFileChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFileUploadOptions.Serialization.cs b/src/Generated/Models/InternalFileUploadOptions.Serialization.cs index 8a86ad75..8f58c008 100644 --- a/src/Generated/Models/InternalFileUploadOptions.Serialization.cs +++ b/src/Generated/Models/InternalFileUploadOptions.Serialization.cs @@ -9,169 +9,168 @@ using System.IO; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalFileUploadOptions : IJsonModel { - internal partial class InternalFileUploadOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file") != true) - { - writer.WritePropertyName("file"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file") != true) + { + writer.WritePropertyName("file"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(global::System.BinaryData.FromStream(File)); #else - using (JsonDocument document = JsonDocument.Parse(BinaryData.FromStream(File))) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) + using (JsonDocument document = JsonDocument.Parse(BinaryData.FromStream(File))) { - writer.WritePropertyName("purpose"u8); - writer.WriteStringValue(Purpose.ToString()); + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } #endif - } - } - writer.WriteEndObject(); } - - InternalFileUploadOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFileUploadOptions(document.RootElement, options); + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose.ToString()); } - - internal static InternalFileUploadOptions DeserializeInternalFileUploadOptions(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) + foreach (var item in SerializedAdditionalRawData) { - return null; - } - Stream file = default; - FileUploadPurpose purpose = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("file"u8)) - { - file = BinaryData.FromString(property.Value.GetRawText()).ToStream(); - continue; - } - if (property.NameEquals("purpose"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - purpose = new FileUploadPurpose(property.Value.GetString()); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFileUploadOptions(file, purpose, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + InternalFileUploadOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); - using MemoryStream stream = new MemoryStream(); - content.WriteTo(stream); - if (stream.Position > int.MaxValue) - { - return BinaryData.FromStream(stream); - } - else - { - return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); - } + throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support reading '{format}' format."); } - internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileUploadOptions(document.RootElement, options); + } + + internal static InternalFileUploadOptions DeserializeInternalFileUploadOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) { - MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); - content.Add(File, "file", "file", "application/octet-stream"); - content.Add(Purpose.ToString(), "purpose"); - return content; + return null; } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + Stream file = default; + FileUploadPurpose purpose = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("file"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - case "MFD": - return SerializeMultipart(options); - default: - throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support writing '{options.Format}' format."); + file = BinaryData.FromString(property.Value.GetRawText()).ToStream(); + continue; + } + if (property.NameEquals("purpose"u8)) + { + purpose = new FileUploadPurpose(property.Value.GetString()); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFileUploadOptions(file, purpose, serializedAdditionalRawData); + } - InternalFileUploadOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + private BinaryData SerializeMultipart(ModelReaderWriterOptions options) + { + using MultipartFormDataBinaryContent content = ToMultipartBinaryBody(); + using MemoryStream stream = new MemoryStream(); + content.WriteTo(stream); + if (stream.Position > int.MaxValue) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFileUploadOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support reading '{options.Format}' format."); - } + return BinaryData.FromStream(stream); } + else + { + return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position)); + } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + internal virtual MultipartFormDataBinaryContent ToMultipartBinaryBody() + { + MultipartFormDataBinaryContent content = new MultipartFormDataBinaryContent(); + content.Add(File, "file", "file", "application/octet-stream"); + content.Add(Purpose.ToString(), "purpose"); + return content; + } - internal static InternalFileUploadOptions FromResponse(PipelineResponse response) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFileUploadOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + case "MFD": + return SerializeMultipart(options); + default: + throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support writing '{options.Format}' format."); } + } + + InternalFileUploadOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFileUploadOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileUploadOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "MFD"; + + internal static InternalFileUploadOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFileUploadOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFileUploadOptions.cs b/src/Generated/Models/InternalFileUploadOptions.cs index 7873ae62..c993471f 100644 --- a/src/Generated/Models/InternalFileUploadOptions.cs +++ b/src/Generated/Models/InternalFileUploadOptions.cs @@ -6,17 +6,16 @@ using System.Collections.Generic; using System.IO; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalFileUploadOptions { - internal partial class InternalFileUploadOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalFileUploadOptions(Stream file, FileUploadPurpose purpose, IDictionary serializedAdditionalRawData) - { - File = file; - Purpose = purpose; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal InternalFileUploadOptions(Stream file, FileUploadPurpose purpose, IDictionary serializedAdditionalRawData) + { + File = file; + Purpose = purpose; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs index 72d9dbab..033b5911 100644 --- a/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs +++ b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.Serialization.cs @@ -9,226 +9,225 @@ using System.Text.Json; using OpenAI.Chat; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuneChatCompletionRequestAssistantMessage : IJsonModel { - internal partial class InternalFineTuneChatCompletionRequestAssistantMessage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("refusal") != true && Optional.IsDefined(Refusal)) - { - if (Refusal != null) - { - writer.WritePropertyName("refusal"u8); - writer.WriteStringValue(Refusal); - } - else - { - writer.WriteNull("refusal"); - } - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(ParticipantName)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("refusal") != true && Optional.IsDefined(Refusal)) + { + if (Refusal != null) { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(ParticipantName); + writer.WritePropertyName("refusal"u8); + writer.WriteStringValue(Refusal); } - if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true && Optional.IsCollectionDefined(ToolCalls)) + else { - writer.WritePropertyName("tool_calls"u8); - writer.WriteStartArray(); - foreach (var item in ToolCalls) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteNull("refusal"); } - if (SerializedAdditionalRawData?.ContainsKey("function_call") != true && Optional.IsDefined(FunctionCall)) + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(ParticipantName)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(ParticipantName); + } + if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true && Optional.IsCollectionDefined(ToolCalls)) + { + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) { - if (FunctionCall != null) - { - writer.WritePropertyName("function_call"u8); - writer.WriteObjectValue(FunctionCall, options); - } - else - { - writer.WriteNull("function_call"); - } + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("role") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("function_call") != true && Optional.IsDefined(FunctionCall)) + { + if (FunctionCall != null) { - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); + writer.WritePropertyName("function_call"u8); + writer.WriteObjectValue(FunctionCall, options); } - if (SerializedAdditionalRawData?.ContainsKey("content") != true && Optional.IsCollectionDefined(Content)) + else { - writer.WritePropertyName("content"u8); - SerializeContentValue(writer, options); + writer.WriteNull("function_call"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData?.ContainsKey("role") != true) + { + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("content") != true && Optional.IsCollectionDefined(Content)) + { + writer.WritePropertyName("content"u8); + SerializeContentValue(writer, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFineTuneChatCompletionRequestAssistantMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFineTuneChatCompletionRequestAssistantMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support reading '{format}' format."); } - internal static InternalFineTuneChatCompletionRequestAssistantMessage DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string refusal = default; - string name = default; - IList toolCalls = default; - ChatFunctionCall functionCall = default; - ChatMessageRole role = default; - IList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalFineTuneChatCompletionRequestAssistantMessage DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string refusal = default; + string name = default; + IList toolCalls = default; + ChatFunctionCall functionCall = default; + ChatMessageRole role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("refusal"u8)) { - if (property.NameEquals("refusal"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - refusal = null; - continue; - } - refusal = property.Value.GetString(); + refusal = null; continue; } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("tool_calls"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatToolCall.DeserializeChatToolCall(item, options)); - } - toolCalls = array; - continue; - } - if (property.NameEquals("function_call"u8)) + refusal = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - functionCall = null; - continue; - } - functionCall = ChatFunctionCall.DeserializeChatFunctionCall(property.Value, options); continue; } - if (property.NameEquals("role"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - role = property.Value.GetString().ToChatMessageRole(); - continue; + array.Add(ChatToolCall.DeserializeChatToolCall(item, options)); } - if (property.NameEquals("content"u8)) + toolCalls = array; + continue; + } + if (property.NameEquals("function_call"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - DeserializeContentValue(property, ref content); + functionCall = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + functionCall = ChatFunctionCall.DeserializeChatFunctionCall(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFineTuneChatCompletionRequestAssistantMessage( - role, - content ?? new ChangeTrackingList(), - serializedAdditionalRawData, - refusal, - name, - toolCalls ?? new ChangeTrackingList(), - functionCall); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("role"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support writing '{options.Format}' format."); + role = property.Value.GetString().ToChatMessageRole(); + continue; } - } - - InternalFineTuneChatCompletionRequestAssistantMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("content"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support reading '{options.Format}' format."); + DeserializeContentValue(property, ref content); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFineTuneChatCompletionRequestAssistantMessage( + role, + content ?? new ChangeTrackingList(), + serializedAdditionalRawData, + refusal, + name, + toolCalls ?? new ChangeTrackingList(), + functionCall); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalFineTuneChatCompletionRequestAssistantMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalFineTuneChatCompletionRequestAssistantMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuneChatCompletionRequestAssistantMessage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalFineTuneChatCompletionRequestAssistantMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFineTuneChatCompletionRequestAssistantMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs index e7f33bc5..19e353de 100644 --- a/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs +++ b/src/Generated/Models/InternalFineTuneChatCompletionRequestAssistantMessage.cs @@ -6,16 +6,15 @@ using System.Collections.Generic; using OpenAI.Chat; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuneChatCompletionRequestAssistantMessage : AssistantChatMessage { - internal partial class InternalFineTuneChatCompletionRequestAssistantMessage : AssistantChatMessage + public InternalFineTuneChatCompletionRequestAssistantMessage() { - public InternalFineTuneChatCompletionRequestAssistantMessage() - { - } + } - internal InternalFineTuneChatCompletionRequestAssistantMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall) : base(role, content, serializedAdditionalRawData, refusal, participantName, toolCalls, functionCall) - { - } + internal InternalFineTuneChatCompletionRequestAssistantMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string refusal, string participantName, IList toolCalls, ChatFunctionCall functionCall) : base(role, content, serializedAdditionalRawData, refusal, participantName, toolCalls, functionCall) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningIntegration.Serialization.cs b/src/Generated/Models/InternalFineTuningIntegration.Serialization.cs index c6cdd8c1..d9b258c8 100644 --- a/src/Generated/Models/InternalFineTuningIntegration.Serialization.cs +++ b/src/Generated/Models/InternalFineTuningIntegration.Serialization.cs @@ -7,117 +7,116 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +[PersistableModelProxy(typeof(UnknownFineTuningIntegration))] +internal partial class InternalFineTuningIntegration : IJsonModel { - [PersistableModelProxy(typeof(UnknownFineTuningIntegration))] - internal partial class InternalFineTuningIntegration : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFineTuningIntegration(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{format}' format."); } - internal static InternalFineTuningIntegration DeserializeInternalFineTuningIntegration(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuningIntegration(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "wandb": return InternalFineTuningIntegrationWandb.DeserializeInternalFineTuningIntegrationWandb(element, options); - } - } - return UnknownFineTuningIntegration.DeserializeUnknownFineTuningIntegration(element, options); - } + internal static InternalFineTuningIntegration DeserializeInternalFineTuningIntegration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalFineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFineTuningIntegration(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{options.Format}' format."); + case "wandb": return InternalFineTuningIntegrationWandb.DeserializeInternalFineTuningIntegrationWandb(element, options); } } + return UnknownFineTuningIntegration.DeserializeUnknownFineTuningIntegration(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFineTuningIntegration FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFineTuningIntegration(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalFineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFineTuningIntegration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFineTuningIntegration FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFineTuningIntegration(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningIntegration.cs b/src/Generated/Models/InternalFineTuningIntegration.cs index 4ee21aa0..264b0328 100644 --- a/src/Generated/Models/InternalFineTuningIntegration.cs +++ b/src/Generated/Models/InternalFineTuningIntegration.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal abstract partial class InternalFineTuningIntegration { - internal abstract partial class InternalFineTuningIntegration + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalFineTuningIntegration() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalFineTuningIntegration() - { - } - - internal InternalFineTuningIntegration(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalFineTuningIntegration(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningIntegrationWandb.Serialization.cs b/src/Generated/Models/InternalFineTuningIntegrationWandb.Serialization.cs index a8ff8e64..87ccb6a3 100644 --- a/src/Generated/Models/InternalFineTuningIntegrationWandb.Serialization.cs +++ b/src/Generated/Models/InternalFineTuningIntegrationWandb.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuningIntegrationWandb : IJsonModel { - internal partial class InternalFineTuningIntegrationWandb : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("wandb") != true) - { - writer.WritePropertyName("wandb"u8); - writer.WriteObjectValue(Wandb, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("wandb") != true) + { + writer.WritePropertyName("wandb"u8); + writer.WriteObjectValue(Wandb, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFineTuningIntegrationWandb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFineTuningIntegrationWandb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFineTuningIntegrationWandb(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support reading '{format}' format."); } - internal static InternalFineTuningIntegrationWandb DeserializeInternalFineTuningIntegrationWandb(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuningIntegrationWandb(document.RootElement, options); + } + + internal static InternalFineTuningIntegrationWandb DeserializeInternalFineTuningIntegrationWandb(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FineTuningIntegrationWandbWandb wandb = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("wandb"u8)) { - return null; + wandb = FineTuningIntegrationWandbWandb.DeserializeFineTuningIntegrationWandbWandb(property.Value, options); + continue; } - FineTuningIntegrationWandbWandb wandb = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("wandb"u8)) - { - wandb = FineTuningIntegrationWandbWandb.DeserializeFineTuningIntegrationWandbWandb(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFineTuningIntegrationWandb(type, serializedAdditionalRawData, wandb); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFineTuningIntegrationWandb(type, serializedAdditionalRawData, wandb); + } - InternalFineTuningIntegrationWandb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFineTuningIntegrationWandb(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalFineTuningIntegrationWandb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalFineTuningIntegrationWandb FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFineTuningIntegrationWandb(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFineTuningIntegrationWandb(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuningIntegrationWandb)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalFineTuningIntegrationWandb FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFineTuningIntegrationWandb(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningIntegrationWandb.cs b/src/Generated/Models/InternalFineTuningIntegrationWandb.cs index 02a6deab..1fb27337 100644 --- a/src/Generated/Models/InternalFineTuningIntegrationWandb.cs +++ b/src/Generated/Models/InternalFineTuningIntegrationWandb.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuningIntegrationWandb : InternalFineTuningIntegration { - internal partial class InternalFineTuningIntegrationWandb : InternalFineTuningIntegration + internal InternalFineTuningIntegrationWandb(FineTuningIntegrationWandbWandb wandb) { - internal InternalFineTuningIntegrationWandb(FineTuningIntegrationWandbWandb wandb) - { - Argument.AssertNotNull(wandb, nameof(wandb)); - - Type = "wandb"; - Wandb = wandb; - } + Argument.AssertNotNull(wandb, nameof(wandb)); - internal InternalFineTuningIntegrationWandb(string type, IDictionary serializedAdditionalRawData, FineTuningIntegrationWandbWandb wandb) : base(type, serializedAdditionalRawData) - { - Wandb = wandb; - } + Type = "wandb"; + Wandb = wandb; + } - internal InternalFineTuningIntegrationWandb() - { - } + internal InternalFineTuningIntegrationWandb(string type, IDictionary serializedAdditionalRawData, FineTuningIntegrationWandbWandb wandb) : base(type, serializedAdditionalRawData) + { + Wandb = wandb; + } - public FineTuningIntegrationWandbWandb Wandb { get; } + internal InternalFineTuningIntegrationWandb() + { } -} + + public FineTuningIntegrationWandbWandb Wandb { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningJobCheckpoint.Serialization.cs b/src/Generated/Models/InternalFineTuningJobCheckpoint.Serialization.cs index d562b0cb..0e9d56e2 100644 --- a/src/Generated/Models/InternalFineTuningJobCheckpoint.Serialization.cs +++ b/src/Generated/Models/InternalFineTuningJobCheckpoint.Serialization.cs @@ -8,200 +8,199 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuningJobCheckpoint : IJsonModel { - internal partial class InternalFineTuningJobCheckpoint : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("fine_tuned_model_checkpoint") != true) + { + writer.WritePropertyName("fine_tuned_model_checkpoint"u8); + writer.WriteStringValue(FineTunedModelCheckpoint); + } + if (SerializedAdditionalRawData?.ContainsKey("step_number") != true) + { + writer.WritePropertyName("step_number"u8); + writer.WriteNumberValue(StepNumber); + } + if (SerializedAdditionalRawData?.ContainsKey("metrics") != true) + { + writer.WritePropertyName("metrics"u8); + writer.WriteObjectValue(Metrics, options); + } + if (SerializedAdditionalRawData?.ContainsKey("fine_tuning_job_id") != true) + { + writer.WritePropertyName("fine_tuning_job_id"u8); + writer.WriteStringValue(FineTuningJobId); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support writing '{format}' format."); + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif } + } + writer.WriteEndObject(); + } + + InternalFineTuningJobCheckpoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support reading '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuningJobCheckpoint(document.RootElement, options); + } + + internal static InternalFineTuningJobCheckpoint DeserializeInternalFineTuningJobCheckpoint(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + DateTimeOffset createdAt = default; + string fineTunedModelCheckpoint = default; + int stepNumber = default; + InternalFineTuningJobCheckpointMetrics metrics = default; + string fineTuningJobId = default; + InternalFineTuningJobCheckpointObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + id = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + if (property.NameEquals("created_at"u8)) { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("fine_tuned_model_checkpoint") != true) + if (property.NameEquals("fine_tuned_model_checkpoint"u8)) { - writer.WritePropertyName("fine_tuned_model_checkpoint"u8); - writer.WriteStringValue(FineTunedModelCheckpoint); + fineTunedModelCheckpoint = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("step_number") != true) + if (property.NameEquals("step_number"u8)) { - writer.WritePropertyName("step_number"u8); - writer.WriteNumberValue(StepNumber); + stepNumber = property.Value.GetInt32(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("metrics") != true) + if (property.NameEquals("metrics"u8)) { - writer.WritePropertyName("metrics"u8); - writer.WriteObjectValue(Metrics, options); + metrics = InternalFineTuningJobCheckpointMetrics.DeserializeInternalFineTuningJobCheckpointMetrics(property.Value, options); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("fine_tuning_job_id") != true) + if (property.NameEquals("fine_tuning_job_id"u8)) { - writer.WritePropertyName("fine_tuning_job_id"u8); - writer.WriteStringValue(FineTuningJobId); + fineTuningJobId = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + if (property.NameEquals("object"u8)) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + @object = new InternalFineTuningJobCheckpointObject(property.Value.GetString()); + continue; } - if (SerializedAdditionalRawData != null) + if (true) { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - writer.WriteEndObject(); } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFineTuningJobCheckpoint( + id, + createdAt, + fineTunedModelCheckpoint, + stepNumber, + metrics, + fineTuningJobId, + @object, + serializedAdditionalRawData); + } - InternalFineTuningJobCheckpoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFineTuningJobCheckpoint(document.RootElement, options); - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFineTuningJobCheckpoint DeserializeInternalFineTuningJobCheckpoint(JsonElement element, ModelReaderWriterOptions options = null) + switch (format) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - DateTimeOffset createdAt = default; - string fineTunedModelCheckpoint = default; - int stepNumber = default; - InternalFineTuningJobCheckpointMetrics metrics = default; - string fineTuningJobId = default; - InternalFineTuningJobCheckpointObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("fine_tuned_model_checkpoint"u8)) - { - fineTunedModelCheckpoint = property.Value.GetString(); - continue; - } - if (property.NameEquals("step_number"u8)) - { - stepNumber = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("metrics"u8)) - { - metrics = InternalFineTuningJobCheckpointMetrics.DeserializeInternalFineTuningJobCheckpointMetrics(property.Value, options); - continue; - } - if (property.NameEquals("fine_tuning_job_id"u8)) - { - fineTuningJobId = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalFineTuningJobCheckpointObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFineTuningJobCheckpoint( - id, - createdAt, - fineTunedModelCheckpoint, - stepNumber, - metrics, - fineTuningJobId, - @object, - serializedAdditionalRawData); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support writing '{options.Format}' format."); } + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support writing '{options.Format}' format."); - } - } + InternalFineTuningJobCheckpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - InternalFineTuningJobCheckpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFineTuningJobCheckpoint(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support reading '{options.Format}' format."); - } + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFineTuningJobCheckpoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpoint)} does not support reading '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - internal static InternalFineTuningJobCheckpoint FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFineTuningJobCheckpoint(document.RootElement); - } + internal static InternalFineTuningJobCheckpoint FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFineTuningJobCheckpoint(document.RootElement); + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningJobCheckpoint.cs b/src/Generated/Models/InternalFineTuningJobCheckpoint.cs index 463cfd4f..6bf6f116 100644 --- a/src/Generated/Models/InternalFineTuningJobCheckpoint.cs +++ b/src/Generated/Models/InternalFineTuningJobCheckpoint.cs @@ -5,48 +5,47 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuningJobCheckpoint { - internal partial class InternalFineTuningJobCheckpoint + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalFineTuningJobCheckpoint(string id, DateTimeOffset createdAt, string fineTunedModelCheckpoint, int stepNumber, InternalFineTuningJobCheckpointMetrics metrics, string fineTuningJobId) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(fineTunedModelCheckpoint, nameof(fineTunedModelCheckpoint)); + Argument.AssertNotNull(metrics, nameof(metrics)); + Argument.AssertNotNull(fineTuningJobId, nameof(fineTuningJobId)); + + Id = id; + CreatedAt = createdAt; + FineTunedModelCheckpoint = fineTunedModelCheckpoint; + StepNumber = stepNumber; + Metrics = metrics; + FineTuningJobId = fineTuningJobId; + } + + internal InternalFineTuningJobCheckpoint(string id, DateTimeOffset createdAt, string fineTunedModelCheckpoint, int stepNumber, InternalFineTuningJobCheckpointMetrics metrics, string fineTuningJobId, InternalFineTuningJobCheckpointObject @object, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalFineTuningJobCheckpoint(string id, DateTimeOffset createdAt, string fineTunedModelCheckpoint, int stepNumber, InternalFineTuningJobCheckpointMetrics metrics, string fineTuningJobId) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(fineTunedModelCheckpoint, nameof(fineTunedModelCheckpoint)); - Argument.AssertNotNull(metrics, nameof(metrics)); - Argument.AssertNotNull(fineTuningJobId, nameof(fineTuningJobId)); - - Id = id; - CreatedAt = createdAt; - FineTunedModelCheckpoint = fineTunedModelCheckpoint; - StepNumber = stepNumber; - Metrics = metrics; - FineTuningJobId = fineTuningJobId; - } - - internal InternalFineTuningJobCheckpoint(string id, DateTimeOffset createdAt, string fineTunedModelCheckpoint, int stepNumber, InternalFineTuningJobCheckpointMetrics metrics, string fineTuningJobId, InternalFineTuningJobCheckpointObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - CreatedAt = createdAt; - FineTunedModelCheckpoint = fineTunedModelCheckpoint; - StepNumber = stepNumber; - Metrics = metrics; - FineTuningJobId = fineTuningJobId; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalFineTuningJobCheckpoint() - { - } - - public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public string FineTunedModelCheckpoint { get; } - public int StepNumber { get; } - public InternalFineTuningJobCheckpointMetrics Metrics { get; } - public string FineTuningJobId { get; } - public InternalFineTuningJobCheckpointObject Object { get; } = InternalFineTuningJobCheckpointObject.FineTuningJobCheckpoint; + Id = id; + CreatedAt = createdAt; + FineTunedModelCheckpoint = fineTunedModelCheckpoint; + StepNumber = stepNumber; + Metrics = metrics; + FineTuningJobId = fineTuningJobId; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalFineTuningJobCheckpoint() + { + } + + public string Id { get; } + public DateTimeOffset CreatedAt { get; } + public string FineTunedModelCheckpoint { get; } + public int StepNumber { get; } + public InternalFineTuningJobCheckpointMetrics Metrics { get; } + public string FineTuningJobId { get; } + public InternalFineTuningJobCheckpointObject Object { get; } = InternalFineTuningJobCheckpointObject.FineTuningJobCheckpoint; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.Serialization.cs b/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.Serialization.cs index 3c411f90..fd3e47d7 100644 --- a/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.Serialization.cs +++ b/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.Serialization.cs @@ -8,228 +8,227 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuningJobCheckpointMetrics : IJsonModel { - internal partial class InternalFineTuningJobCheckpointMetrics : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("step") != true && Optional.IsDefined(Step)) - { - writer.WritePropertyName("step"u8); - writer.WriteNumberValue(Step.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("train_loss") != true && Optional.IsDefined(TrainLoss)) - { - writer.WritePropertyName("train_loss"u8); - writer.WriteNumberValue(TrainLoss.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("train_mean_token_accuracy") != true && Optional.IsDefined(TrainMeanTokenAccuracy)) - { - writer.WritePropertyName("train_mean_token_accuracy"u8); - writer.WriteNumberValue(TrainMeanTokenAccuracy.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("valid_loss") != true && Optional.IsDefined(ValidLoss)) - { - writer.WritePropertyName("valid_loss"u8); - writer.WriteNumberValue(ValidLoss.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("valid_mean_token_accuracy") != true && Optional.IsDefined(ValidMeanTokenAccuracy)) - { - writer.WritePropertyName("valid_mean_token_accuracy"u8); - writer.WriteNumberValue(ValidMeanTokenAccuracy.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("full_valid_loss") != true && Optional.IsDefined(FullValidLoss)) - { - writer.WritePropertyName("full_valid_loss"u8); - writer.WriteNumberValue(FullValidLoss.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("full_valid_mean_token_accuracy") != true && Optional.IsDefined(FullValidMeanTokenAccuracy)) - { - writer.WritePropertyName("full_valid_mean_token_accuracy"u8); - writer.WriteNumberValue(FullValidMeanTokenAccuracy.Value); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("step") != true && Optional.IsDefined(Step)) + { + writer.WritePropertyName("step"u8); + writer.WriteNumberValue(Step.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("train_loss") != true && Optional.IsDefined(TrainLoss)) + { + writer.WritePropertyName("train_loss"u8); + writer.WriteNumberValue(TrainLoss.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("train_mean_token_accuracy") != true && Optional.IsDefined(TrainMeanTokenAccuracy)) + { + writer.WritePropertyName("train_mean_token_accuracy"u8); + writer.WriteNumberValue(TrainMeanTokenAccuracy.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("valid_loss") != true && Optional.IsDefined(ValidLoss)) + { + writer.WritePropertyName("valid_loss"u8); + writer.WriteNumberValue(ValidLoss.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("valid_mean_token_accuracy") != true && Optional.IsDefined(ValidMeanTokenAccuracy)) + { + writer.WritePropertyName("valid_mean_token_accuracy"u8); + writer.WriteNumberValue(ValidMeanTokenAccuracy.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("full_valid_loss") != true && Optional.IsDefined(FullValidLoss)) + { + writer.WritePropertyName("full_valid_loss"u8); + writer.WriteNumberValue(FullValidLoss.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("full_valid_mean_token_accuracy") != true && Optional.IsDefined(FullValidMeanTokenAccuracy)) + { + writer.WritePropertyName("full_valid_mean_token_accuracy"u8); + writer.WriteNumberValue(FullValidMeanTokenAccuracy.Value); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFineTuningJobCheckpointMetrics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFineTuningJobCheckpointMetrics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFineTuningJobCheckpointMetrics(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support reading '{format}' format."); } - internal static InternalFineTuningJobCheckpointMetrics DeserializeInternalFineTuningJobCheckpointMetrics(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuningJobCheckpointMetrics(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - float? step = default; - float? trainLoss = default; - float? trainMeanTokenAccuracy = default; - float? validLoss = default; - float? validMeanTokenAccuracy = default; - float? fullValidLoss = default; - float? fullValidMeanTokenAccuracy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalFineTuningJobCheckpointMetrics DeserializeInternalFineTuningJobCheckpointMetrics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + float? step = default; + float? trainLoss = default; + float? trainMeanTokenAccuracy = default; + float? validLoss = default; + float? validMeanTokenAccuracy = default; + float? fullValidLoss = default; + float? fullValidMeanTokenAccuracy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("step"u8)) { - if (property.NameEquals("step"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - step = property.Value.GetSingle(); continue; } - if (property.NameEquals("train_loss"u8)) + step = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("train_loss"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - trainLoss = property.Value.GetSingle(); continue; } - if (property.NameEquals("train_mean_token_accuracy"u8)) + trainLoss = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("train_mean_token_accuracy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - trainMeanTokenAccuracy = property.Value.GetSingle(); continue; } - if (property.NameEquals("valid_loss"u8)) + trainMeanTokenAccuracy = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("valid_loss"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - validLoss = property.Value.GetSingle(); continue; } - if (property.NameEquals("valid_mean_token_accuracy"u8)) + validLoss = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("valid_mean_token_accuracy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - validMeanTokenAccuracy = property.Value.GetSingle(); continue; } - if (property.NameEquals("full_valid_loss"u8)) + validMeanTokenAccuracy = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("full_valid_loss"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fullValidLoss = property.Value.GetSingle(); continue; } - if (property.NameEquals("full_valid_mean_token_accuracy"u8)) + fullValidLoss = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("full_valid_mean_token_accuracy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fullValidMeanTokenAccuracy = property.Value.GetSingle(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fullValidMeanTokenAccuracy = property.Value.GetSingle(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFineTuningJobCheckpointMetrics( - step, - trainLoss, - trainMeanTokenAccuracy, - validLoss, - validMeanTokenAccuracy, - fullValidLoss, - fullValidMeanTokenAccuracy, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFineTuningJobCheckpointMetrics( + step, + trainLoss, + trainMeanTokenAccuracy, + validLoss, + validMeanTokenAccuracy, + fullValidLoss, + fullValidMeanTokenAccuracy, + serializedAdditionalRawData); + } - InternalFineTuningJobCheckpointMetrics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFineTuningJobCheckpointMetrics(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalFineTuningJobCheckpointMetrics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFineTuningJobCheckpointMetrics FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFineTuningJobCheckpointMetrics(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFineTuningJobCheckpointMetrics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuningJobCheckpointMetrics)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFineTuningJobCheckpointMetrics FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFineTuningJobCheckpointMetrics(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.cs b/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.cs index 63c7256e..ec9bda00 100644 --- a/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.cs +++ b/src/Generated/Models/InternalFineTuningJobCheckpointMetrics.cs @@ -5,33 +5,32 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFineTuningJobCheckpointMetrics { - internal partial class InternalFineTuningJobCheckpointMetrics + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalFineTuningJobCheckpointMetrics() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalFineTuningJobCheckpointMetrics() - { - } - - internal InternalFineTuningJobCheckpointMetrics(float? step, float? trainLoss, float? trainMeanTokenAccuracy, float? validLoss, float? validMeanTokenAccuracy, float? fullValidLoss, float? fullValidMeanTokenAccuracy, IDictionary serializedAdditionalRawData) - { - Step = step; - TrainLoss = trainLoss; - TrainMeanTokenAccuracy = trainMeanTokenAccuracy; - ValidLoss = validLoss; - ValidMeanTokenAccuracy = validMeanTokenAccuracy; - FullValidLoss = fullValidLoss; - FullValidMeanTokenAccuracy = fullValidMeanTokenAccuracy; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public float? Step { get; } - public float? TrainLoss { get; } - public float? TrainMeanTokenAccuracy { get; } - public float? ValidLoss { get; } - public float? ValidMeanTokenAccuracy { get; } - public float? FullValidLoss { get; } - public float? FullValidMeanTokenAccuracy { get; } + internal InternalFineTuningJobCheckpointMetrics(float? step, float? trainLoss, float? trainMeanTokenAccuracy, float? validLoss, float? validMeanTokenAccuracy, float? fullValidLoss, float? fullValidMeanTokenAccuracy, IDictionary serializedAdditionalRawData) + { + Step = step; + TrainLoss = trainLoss; + TrainMeanTokenAccuracy = trainMeanTokenAccuracy; + ValidLoss = validLoss; + ValidMeanTokenAccuracy = validMeanTokenAccuracy; + FullValidLoss = fullValidLoss; + FullValidMeanTokenAccuracy = fullValidMeanTokenAccuracy; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public float? Step { get; } + public float? TrainLoss { get; } + public float? TrainMeanTokenAccuracy { get; } + public float? ValidLoss { get; } + public float? ValidMeanTokenAccuracy { get; } + public float? FullValidLoss { get; } + public float? FullValidMeanTokenAccuracy { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningJobCheckpointObject.cs b/src/Generated/Models/InternalFineTuningJobCheckpointObject.cs index 5cdd24ad..7bf813d3 100644 --- a/src/Generated/Models/InternalFineTuningJobCheckpointObject.cs +++ b/src/Generated/Models/InternalFineTuningJobCheckpointObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct InternalFineTuningJobCheckpointObject : IEquatable { - internal readonly partial struct InternalFineTuningJobCheckpointObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalFineTuningJobCheckpointObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalFineTuningJobCheckpointObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FineTuningJobCheckpointValue = "fine_tuning.job.checkpoint"; + private const string FineTuningJobCheckpointValue = "fine_tuning.job.checkpoint"; - public static InternalFineTuningJobCheckpointObject FineTuningJobCheckpoint { get; } = new InternalFineTuningJobCheckpointObject(FineTuningJobCheckpointValue); - public static bool operator ==(InternalFineTuningJobCheckpointObject left, InternalFineTuningJobCheckpointObject right) => left.Equals(right); - public static bool operator !=(InternalFineTuningJobCheckpointObject left, InternalFineTuningJobCheckpointObject right) => !left.Equals(right); - public static implicit operator InternalFineTuningJobCheckpointObject(string value) => new InternalFineTuningJobCheckpointObject(value); + public static InternalFineTuningJobCheckpointObject FineTuningJobCheckpoint { get; } = new InternalFineTuningJobCheckpointObject(FineTuningJobCheckpointValue); + public static bool operator ==(InternalFineTuningJobCheckpointObject left, InternalFineTuningJobCheckpointObject right) => left.Equals(right); + public static bool operator !=(InternalFineTuningJobCheckpointObject left, InternalFineTuningJobCheckpointObject right) => !left.Equals(right); + public static implicit operator InternalFineTuningJobCheckpointObject(string value) => new InternalFineTuningJobCheckpointObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalFineTuningJobCheckpointObject other && Equals(other); - public bool Equals(InternalFineTuningJobCheckpointObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalFineTuningJobCheckpointObject other && Equals(other); + public bool Equals(InternalFineTuningJobCheckpointObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningJobEventObject.cs b/src/Generated/Models/InternalFineTuningJobEventObject.cs index 04fdff4d..0208749a 100644 --- a/src/Generated/Models/InternalFineTuningJobEventObject.cs +++ b/src/Generated/Models/InternalFineTuningJobEventObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct InternalFineTuningJobEventObject : IEquatable { - internal readonly partial struct InternalFineTuningJobEventObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalFineTuningJobEventObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalFineTuningJobEventObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FineTuningJobEventValue = "fine_tuning.job.event"; + private const string FineTuningJobEventValue = "fine_tuning.job.event"; - public static InternalFineTuningJobEventObject FineTuningJobEvent { get; } = new InternalFineTuningJobEventObject(FineTuningJobEventValue); - public static bool operator ==(InternalFineTuningJobEventObject left, InternalFineTuningJobEventObject right) => left.Equals(right); - public static bool operator !=(InternalFineTuningJobEventObject left, InternalFineTuningJobEventObject right) => !left.Equals(right); - public static implicit operator InternalFineTuningJobEventObject(string value) => new InternalFineTuningJobEventObject(value); + public static InternalFineTuningJobEventObject FineTuningJobEvent { get; } = new InternalFineTuningJobEventObject(FineTuningJobEventValue); + public static bool operator ==(InternalFineTuningJobEventObject left, InternalFineTuningJobEventObject right) => left.Equals(right); + public static bool operator !=(InternalFineTuningJobEventObject left, InternalFineTuningJobEventObject right) => !left.Equals(right); + public static implicit operator InternalFineTuningJobEventObject(string value) => new InternalFineTuningJobEventObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalFineTuningJobEventObject other && Equals(other); - public bool Equals(InternalFineTuningJobEventObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalFineTuningJobEventObject other && Equals(other); + public bool Equals(InternalFineTuningJobEventObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFineTuningJobObject.cs b/src/Generated/Models/InternalFineTuningJobObject.cs index b627e294..d34832df 100644 --- a/src/Generated/Models/InternalFineTuningJobObject.cs +++ b/src/Generated/Models/InternalFineTuningJobObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct InternalFineTuningJobObject : IEquatable { - internal readonly partial struct InternalFineTuningJobObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalFineTuningJobObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalFineTuningJobObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FineTuningJobValue = "fine_tuning.job"; + private const string FineTuningJobValue = "fine_tuning.job"; - public static InternalFineTuningJobObject FineTuningJob { get; } = new InternalFineTuningJobObject(FineTuningJobValue); - public static bool operator ==(InternalFineTuningJobObject left, InternalFineTuningJobObject right) => left.Equals(right); - public static bool operator !=(InternalFineTuningJobObject left, InternalFineTuningJobObject right) => !left.Equals(right); - public static implicit operator InternalFineTuningJobObject(string value) => new InternalFineTuningJobObject(value); + public static InternalFineTuningJobObject FineTuningJob { get; } = new InternalFineTuningJobObject(FineTuningJobValue); + public static bool operator ==(InternalFineTuningJobObject left, InternalFineTuningJobObject right) => left.Equals(right); + public static bool operator !=(InternalFineTuningJobObject left, InternalFineTuningJobObject right) => !left.Equals(right); + public static implicit operator InternalFineTuningJobObject(string value) => new InternalFineTuningJobObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalFineTuningJobObject other && Equals(other); - public bool Equals(InternalFineTuningJobObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalFineTuningJobObject other && Equals(other); + public bool Equals(InternalFineTuningJobObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs b/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs index 946bb2d9..78e7c5ea 100644 --- a/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs +++ b/src/Generated/Models/InternalFinetuneChatRequestInput.Serialization.cs @@ -9,224 +9,223 @@ using System.Text.Json; using OpenAI.Chat; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFinetuneChatRequestInput : IJsonModel { - internal partial class InternalFinetuneChatRequestInput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("messages") != true && Optional.IsCollectionDefined(Messages)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("messages") != true && Optional.IsCollectionDefined(Messages)) + { + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) { - writer.WritePropertyName("messages"u8); - writer.WriteStartArray(); - foreach (var item in Messages) + if (item == null) { - if (item == null) - { - writer.WriteNullValue(); - continue; - } + writer.WriteNullValue(); + continue; + } #if NET6_0_OR_GREATER writer.WriteRawValue(item); #else - using (JsonDocument document = JsonDocument.Parse(item)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) + using (JsonDocument document = JsonDocument.Parse(item)) { - writer.WriteObjectValue(item, options); + JsonSerializer.Serialize(writer, document.RootElement); } - writer.WriteEndArray(); +#endif } - if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCalls)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) { - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCalls.Value); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("functions") != true && Optional.IsCollectionDefined(Functions)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCalls)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("functions") != true && Optional.IsCollectionDefined(Functions)) + { + writer.WritePropertyName("functions"u8); + writer.WriteStartArray(); + foreach (var item in Functions) { - writer.WritePropertyName("functions"u8); - writer.WriteStartArray(); - foreach (var item in Functions) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFinetuneChatRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFinetuneChatRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{format}' format."); } - internal static InternalFinetuneChatRequestInput DeserializeInternalFinetuneChatRequestInput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList messages = default; - IList tools = default; - bool? parallelToolCalls = default; - IList functions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalFinetuneChatRequestInput DeserializeInternalFinetuneChatRequestInput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList messages = default; + IList tools = default; + bool? parallelToolCalls = default; + IList functions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) { - if (property.NameEquals("messages"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(BinaryData.FromString(item.GetRawText())); - } - } - messages = array; continue; } - if (property.NameEquals("tools"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (item.ValueKind == JsonValueKind.Null) { - continue; + array.Add(null); } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + else { - array.Add(ChatTool.DeserializeChatTool(item, options)); + array.Add(BinaryData.FromString(item.GetRawText())); } - tools = array; + } + messages = array; + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { continue; } - if (property.NameEquals("parallel_tool_calls"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatTool.DeserializeChatTool(item, options)); + } + tools = array; + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parallelToolCalls = property.Value.GetBoolean(); continue; } - if (property.NameEquals("functions"u8)) + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("functions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ChatFunction.DeserializeChatFunction(item, options)); - } - functions = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(ChatFunction.DeserializeChatFunction(item, options)); } + functions = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFinetuneChatRequestInput(messages ?? new ChangeTrackingList(), tools ?? new ChangeTrackingList(), parallelToolCalls, functions ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFinetuneChatRequestInput(messages ?? new ChangeTrackingList(), tools ?? new ChangeTrackingList(), parallelToolCalls, functions ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalFinetuneChatRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalFinetuneChatRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFinetuneChatRequestInput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFinetuneChatRequestInput(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFinetuneChatRequestInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFinetuneChatRequestInput)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFinetuneChatRequestInput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFinetuneChatRequestInput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFinetuneChatRequestInput.cs b/src/Generated/Models/InternalFinetuneChatRequestInput.cs index b325ed53..a131018e 100644 --- a/src/Generated/Models/InternalFinetuneChatRequestInput.cs +++ b/src/Generated/Models/InternalFinetuneChatRequestInput.cs @@ -6,30 +6,29 @@ using System.Collections.Generic; using OpenAI.Chat; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFinetuneChatRequestInput { - internal partial class InternalFinetuneChatRequestInput + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalFinetuneChatRequestInput() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalFinetuneChatRequestInput() - { - Messages = new ChangeTrackingList(); - Tools = new ChangeTrackingList(); - Functions = new ChangeTrackingList(); - } - - internal InternalFinetuneChatRequestInput(IList messages, IList tools, bool? parallelToolCalls, IList functions, IDictionary serializedAdditionalRawData) - { - Messages = messages; - Tools = tools; - ParallelToolCalls = parallelToolCalls; - Functions = functions; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Messages = new ChangeTrackingList(); + Tools = new ChangeTrackingList(); + Functions = new ChangeTrackingList(); + } - public IList Messages { get; } - public IList Tools { get; } - public bool? ParallelToolCalls { get; set; } - public IList Functions { get; } + internal InternalFinetuneChatRequestInput(IList messages, IList tools, bool? parallelToolCalls, IList functions, IDictionary serializedAdditionalRawData) + { + Messages = messages; + Tools = tools; + ParallelToolCalls = parallelToolCalls; + Functions = functions; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList Messages { get; } + public IList Tools { get; } + public bool? ParallelToolCalls { get; set; } + public IList Functions { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs b/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs index 5fbbb747..923e47f3 100644 --- a/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs +++ b/src/Generated/Models/InternalFinetuneCompletionRequestInput.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFinetuneCompletionRequestInput : IJsonModel { - internal partial class InternalFinetuneCompletionRequestInput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("prompt") != true && Optional.IsDefined(Prompt)) - { - writer.WritePropertyName("prompt"u8); - writer.WriteStringValue(Prompt); - } - if (SerializedAdditionalRawData?.ContainsKey("completion") != true && Optional.IsDefined(Completion)) - { - writer.WritePropertyName("completion"u8); - writer.WriteStringValue(Completion); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("prompt") != true && Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (SerializedAdditionalRawData?.ContainsKey("completion") != true && Optional.IsDefined(Completion)) + { + writer.WritePropertyName("completion"u8); + writer.WriteStringValue(Completion); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFinetuneCompletionRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFinetuneCompletionRequestInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{format}' format."); } - internal static InternalFinetuneCompletionRequestInput DeserializeInternalFinetuneCompletionRequestInput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); + } + + internal static InternalFinetuneCompletionRequestInput DeserializeInternalFinetuneCompletionRequestInput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string prompt = default; + string completion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("prompt"u8)) { - return null; + prompt = property.Value.GetString(); + continue; } - string prompt = default; - string completion = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("completion"u8)) { - if (property.NameEquals("prompt"u8)) - { - prompt = property.Value.GetString(); - continue; - } - if (property.NameEquals("completion"u8)) - { - completion = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + completion = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFinetuneCompletionRequestInput(prompt, completion, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFinetuneCompletionRequestInput(prompt, completion, serializedAdditionalRawData); + } - InternalFinetuneCompletionRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalFinetuneCompletionRequestInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFinetuneCompletionRequestInput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFinetuneCompletionRequestInput)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFinetuneCompletionRequestInput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFinetuneCompletionRequestInput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs b/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs index 3e30640c..bedc964d 100644 --- a/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs +++ b/src/Generated/Models/InternalFinetuneCompletionRequestInput.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalFinetuneCompletionRequestInput { - internal partial class InternalFinetuneCompletionRequestInput + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalFinetuneCompletionRequestInput() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalFinetuneCompletionRequestInput() - { - } - - internal InternalFinetuneCompletionRequestInput(string prompt, string completion, IDictionary serializedAdditionalRawData) - { - Prompt = prompt; - Completion = completion; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string Prompt { get; set; } - public string Completion { get; set; } + internal InternalFinetuneCompletionRequestInput(string prompt, string completion, IDictionary serializedAdditionalRawData) + { + Prompt = prompt; + Completion = completion; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Prompt { get; set; } + public string Completion { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFunctionDefinition.Serialization.cs b/src/Generated/Models/InternalFunctionDefinition.Serialization.cs index 57335523..dc9701c9 100644 --- a/src/Generated/Models/InternalFunctionDefinition.Serialization.cs +++ b/src/Generated/Models/InternalFunctionDefinition.Serialization.cs @@ -8,182 +8,181 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI +namespace OpenAI; + +internal partial class InternalFunctionDefinition : IJsonModel { - internal partial class InternalFunctionDefinition : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData?.ContainsKey("parameters") != true && Optional.IsDefined(Parameters)) - { - writer.WritePropertyName("parameters"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("parameters") != true && Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Parameters); #else - using (JsonDocument document = JsonDocument.Parse(Parameters)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } #endif + } + if (SerializedAdditionalRawData?.ContainsKey("strict") != true && Optional.IsDefined(Strict)) + { + if (Strict != null) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); } - if (SerializedAdditionalRawData?.ContainsKey("strict") != true && Optional.IsDefined(Strict)) + else { - if (Strict != null) - { - writer.WritePropertyName("strict"u8); - writer.WriteBooleanValue(Strict.Value); - } - else - { - writer.WriteNull("strict"); - } + writer.WriteNull("strict"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFunctionDefinition(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support reading '{format}' format."); } - internal static InternalFunctionDefinition DeserializeInternalFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionDefinition(document.RootElement, options); + } + + internal static InternalFunctionDefinition DeserializeInternalFunctionDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + BinaryData parameters = default; + bool? strict = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) { - return null; + description = property.Value.GetString(); + continue; } - string description = default; - string name = default; - BinaryData parameters = default; - bool? strict = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("description"u8)) - { - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("parameters"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("parameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parameters = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (property.NameEquals("strict"u8)) + parameters = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("strict"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - strict = null; - continue; - } - strict = property.Value.GetBoolean(); + strict = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + strict = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalFunctionDefinition(description, name, parameters, strict, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalFunctionDefinition(description, name, parameters, strict, serializedAdditionalRawData); + } - InternalFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFunctionDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFunctionDefinition FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFunctionDefinition(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionDefinition)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFunctionDefinition FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFunctionDefinition(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFunctionDefinition.cs b/src/Generated/Models/InternalFunctionDefinition.cs index 9e385deb..85811d4e 100644 --- a/src/Generated/Models/InternalFunctionDefinition.cs +++ b/src/Generated/Models/InternalFunctionDefinition.cs @@ -5,33 +5,32 @@ using System; using System.Collections.Generic; -namespace OpenAI +namespace OpenAI; + +internal partial class InternalFunctionDefinition { - internal partial class InternalFunctionDefinition + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalFunctionDefinition(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + internal InternalFunctionDefinition(string description, string name, BinaryData parameters, bool? strict, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalFunctionDefinition(string name) - { - Argument.AssertNotNull(name, nameof(name)); - - Name = name; - } - - internal InternalFunctionDefinition(string description, string name, BinaryData parameters, bool? strict, IDictionary serializedAdditionalRawData) - { - Description = description; - Name = name; - Parameters = parameters; - Strict = strict; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalFunctionDefinition() - { - } - - public string Description { get; set; } - public string Name { get; set; } - public bool? Strict { get; set; } + Description = description; + Name = name; + Parameters = parameters; + Strict = strict; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalFunctionDefinition() + { + } + + public string Description { get; set; } + public string Name { get; set; } + public bool? Strict { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFunctionParameters.Serialization.cs b/src/Generated/Models/InternalFunctionParameters.Serialization.cs index 4ab8c6f4..9cc08856 100644 --- a/src/Generated/Models/InternalFunctionParameters.Serialization.cs +++ b/src/Generated/Models/InternalFunctionParameters.Serialization.cs @@ -8,104 +8,103 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalFunctionParameters : IJsonModel { - internal partial class InternalFunctionParameters : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - foreach (var item in AdditionalProperties) - { - writer.WritePropertyName(item.Key); + writer.WriteStartObject(); + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - writer.WriteEndObject(); +#endif } + writer.WriteEndObject(); + } - InternalFunctionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalFunctionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFunctionParameters(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support reading '{format}' format."); } - internal static InternalFunctionParameters DeserializeInternalFunctionParameters(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionParameters(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary additionalProperties = default; - Dictionary additionalPropertiesDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - additionalProperties = additionalPropertiesDictionary; - return new InternalFunctionParameters(additionalProperties); - } + internal static InternalFunctionParameters DeserializeInternalFunctionParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalFunctionParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFunctionParameters(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support reading '{options.Format}' format."); - } + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } + additionalProperties = additionalPropertiesDictionary; + return new InternalFunctionParameters(additionalProperties); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalFunctionParameters FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalFunctionParameters(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalFunctionParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFunctionParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionParameters)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalFunctionParameters FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalFunctionParameters(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalFunctionParameters.cs b/src/Generated/Models/InternalFunctionParameters.cs index 0320cf60..da56e247 100644 --- a/src/Generated/Models/InternalFunctionParameters.cs +++ b/src/Generated/Models/InternalFunctionParameters.cs @@ -5,20 +5,19 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalFunctionParameters { - internal partial class InternalFunctionParameters + public InternalFunctionParameters() { - public InternalFunctionParameters() - { - AdditionalProperties = new ChangeTrackingDictionary(); - } - - internal InternalFunctionParameters(IDictionary additionalProperties) - { - AdditionalProperties = additionalProperties; - } + AdditionalProperties = new ChangeTrackingDictionary(); + } - public IDictionary AdditionalProperties { get; } + internal InternalFunctionParameters(IDictionary additionalProperties) + { + AdditionalProperties = additionalProperties; } -} + + public IDictionary AdditionalProperties { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListAssistantsResponse.Serialization.cs b/src/Generated/Models/InternalListAssistantsResponse.Serialization.cs index edbc8c76..ba10b772 100644 --- a/src/Generated/Models/InternalListAssistantsResponse.Serialization.cs +++ b/src/Generated/Models/InternalListAssistantsResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListAssistantsResponse : IJsonModel { - internal partial class InternalListAssistantsResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListAssistantsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListAssistantsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListAssistantsResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support reading '{format}' format."); } - internal static InternalListAssistantsResponse DeserializeInternalListAssistantsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListAssistantsResponse(document.RootElement, options); + } + + internal static InternalListAssistantsResponse DeserializeInternalListAssistantsResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalListAssistantsResponseObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - return null; + @object = new InternalListAssistantsResponseObject(property.Value.GetString()); + continue; } - InternalListAssistantsResponseObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListAssistantsResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(Assistant.DeserializeAssistant(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(Assistant.DeserializeAssistant(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListAssistantsResponse( - @object, - data, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListAssistantsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListAssistantsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListAssistantsResponse( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListAssistantsResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListAssistantsResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListAssistantsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListAssistantsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListAssistantsResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListAssistantsResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListAssistantsResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListAssistantsResponse.cs b/src/Generated/Models/InternalListAssistantsResponse.cs index 6ee4c4cc..724eaa84 100644 --- a/src/Generated/Models/InternalListAssistantsResponse.cs +++ b/src/Generated/Models/InternalListAssistantsResponse.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListAssistantsResponse { - internal partial class InternalListAssistantsResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListAssistantsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListAssistantsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - internal InternalListAssistantsResponse(InternalListAssistantsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListAssistantsResponse() - { - } - - public InternalListAssistantsResponseObject Object { get; } = InternalListAssistantsResponseObject.List; - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } -} + + internal InternalListAssistantsResponse(InternalListAssistantsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalListAssistantsResponse() + { + } + + public InternalListAssistantsResponseObject Object { get; } = InternalListAssistantsResponseObject.List; + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListAssistantsResponseObject.cs b/src/Generated/Models/InternalListAssistantsResponseObject.cs index 6d7350e7..df75b070 100644 --- a/src/Generated/Models/InternalListAssistantsResponseObject.cs +++ b/src/Generated/Models/InternalListAssistantsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalListAssistantsResponseObject : IEquatable { - internal readonly partial struct InternalListAssistantsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListAssistantsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListAssistantsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListAssistantsResponseObject List { get; } = new InternalListAssistantsResponseObject(ListValue); - public static bool operator ==(InternalListAssistantsResponseObject left, InternalListAssistantsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListAssistantsResponseObject left, InternalListAssistantsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListAssistantsResponseObject(string value) => new InternalListAssistantsResponseObject(value); + public static InternalListAssistantsResponseObject List { get; } = new InternalListAssistantsResponseObject(ListValue); + public static bool operator ==(InternalListAssistantsResponseObject left, InternalListAssistantsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListAssistantsResponseObject left, InternalListAssistantsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListAssistantsResponseObject(string value) => new InternalListAssistantsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListAssistantsResponseObject other && Equals(other); - public bool Equals(InternalListAssistantsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListAssistantsResponseObject other && Equals(other); + public bool Equals(InternalListAssistantsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListBatchesResponse.Serialization.cs b/src/Generated/Models/InternalListBatchesResponse.Serialization.cs index 432479b4..e0b27f06 100644 --- a/src/Generated/Models/InternalListBatchesResponse.Serialization.cs +++ b/src/Generated/Models/InternalListBatchesResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalListBatchesResponse : IJsonModel { - internal partial class InternalListBatchesResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("data") != true) - { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true && Optional.IsDefined(FirstId)) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true && Optional.IsDefined(LastId)) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true && Optional.IsDefined(FirstId)) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true && Optional.IsDefined(LastId)) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListBatchesResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListBatchesResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListBatchesResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support reading '{format}' format."); } - internal static InternalListBatchesResponse DeserializeInternalListBatchesResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListBatchesResponse(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - InternalListBatchesResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalListBatchesResponse DeserializeInternalListBatchesResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + InternalListBatchesResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("data"u8)) { - if (property.NameEquals("data"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalBatchJob.DeserializeInternalBatchJob(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalListBatchesResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalBatchJob.DeserializeInternalBatchJob(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListBatchesResponse( - data, - firstId, - lastId, - hasMore, - @object, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListBatchesResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListBatchesResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support reading '{options.Format}' format."); + hasMore = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalListBatchesResponseObject(property.Value.GetString()); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListBatchesResponse( + data, + firstId, + lastId, + hasMore, + @object, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListBatchesResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListBatchesResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalListBatchesResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListBatchesResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListBatchesResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListBatchesResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListBatchesResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListBatchesResponse.cs b/src/Generated/Models/InternalListBatchesResponse.cs index c81c672c..c42923a1 100644 --- a/src/Generated/Models/InternalListBatchesResponse.cs +++ b/src/Generated/Models/InternalListBatchesResponse.cs @@ -6,37 +6,36 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal partial class InternalListBatchesResponse { - internal partial class InternalListBatchesResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListBatchesResponse(IEnumerable data, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data.ToList(); + HasMore = hasMore; + } + + internal InternalListBatchesResponse(IReadOnlyList data, string firstId, string lastId, bool hasMore, InternalListBatchesResponseObject @object, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListBatchesResponse(IEnumerable data, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - - Data = data.ToList(); - HasMore = hasMore; - } - - internal InternalListBatchesResponse(IReadOnlyList data, string firstId, string lastId, bool hasMore, InternalListBatchesResponseObject @object, IDictionary serializedAdditionalRawData) - { - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListBatchesResponse() - { - } - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } - public InternalListBatchesResponseObject Object { get; } = InternalListBatchesResponseObject.List; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalListBatchesResponse() + { + } + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } + public InternalListBatchesResponseObject Object { get; } = InternalListBatchesResponseObject.List; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListBatchesResponseObject.cs b/src/Generated/Models/InternalListBatchesResponseObject.cs index 3f562b70..95382d49 100644 --- a/src/Generated/Models/InternalListBatchesResponseObject.cs +++ b/src/Generated/Models/InternalListBatchesResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Batch +namespace OpenAI.Batch; + +internal readonly partial struct InternalListBatchesResponseObject : IEquatable { - internal readonly partial struct InternalListBatchesResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListBatchesResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListBatchesResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListBatchesResponseObject List { get; } = new InternalListBatchesResponseObject(ListValue); - public static bool operator ==(InternalListBatchesResponseObject left, InternalListBatchesResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListBatchesResponseObject left, InternalListBatchesResponseObject right) => !left.Equals(right); - public static implicit operator InternalListBatchesResponseObject(string value) => new InternalListBatchesResponseObject(value); + public static InternalListBatchesResponseObject List { get; } = new InternalListBatchesResponseObject(ListValue); + public static bool operator ==(InternalListBatchesResponseObject left, InternalListBatchesResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListBatchesResponseObject left, InternalListBatchesResponseObject right) => !left.Equals(right); + public static implicit operator InternalListBatchesResponseObject(string value) => new InternalListBatchesResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListBatchesResponseObject other && Equals(other); - public bool Equals(InternalListBatchesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListBatchesResponseObject other && Equals(other); + public bool Equals(InternalListBatchesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFilesInVectorStoreBatchRequestOrder.cs b/src/Generated/Models/InternalListFilesInVectorStoreBatchRequestOrder.cs index 3cabf608..0f08ba4f 100644 --- a/src/Generated/Models/InternalListFilesInVectorStoreBatchRequestOrder.cs +++ b/src/Generated/Models/InternalListFilesInVectorStoreBatchRequestOrder.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalListFilesInVectorStoreBatchRequestOrder : IEquatable { - internal readonly partial struct InternalListFilesInVectorStoreBatchRequestOrder : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListFilesInVectorStoreBatchRequestOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListFilesInVectorStoreBatchRequestOrder(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AscValue = "asc"; - private const string DescValue = "desc"; + private const string AscValue = "asc"; + private const string DescValue = "desc"; - public static InternalListFilesInVectorStoreBatchRequestOrder Asc { get; } = new InternalListFilesInVectorStoreBatchRequestOrder(AscValue); - public static InternalListFilesInVectorStoreBatchRequestOrder Desc { get; } = new InternalListFilesInVectorStoreBatchRequestOrder(DescValue); - public static bool operator ==(InternalListFilesInVectorStoreBatchRequestOrder left, InternalListFilesInVectorStoreBatchRequestOrder right) => left.Equals(right); - public static bool operator !=(InternalListFilesInVectorStoreBatchRequestOrder left, InternalListFilesInVectorStoreBatchRequestOrder right) => !left.Equals(right); - public static implicit operator InternalListFilesInVectorStoreBatchRequestOrder(string value) => new InternalListFilesInVectorStoreBatchRequestOrder(value); + public static InternalListFilesInVectorStoreBatchRequestOrder Asc { get; } = new InternalListFilesInVectorStoreBatchRequestOrder(AscValue); + public static InternalListFilesInVectorStoreBatchRequestOrder Desc { get; } = new InternalListFilesInVectorStoreBatchRequestOrder(DescValue); + public static bool operator ==(InternalListFilesInVectorStoreBatchRequestOrder left, InternalListFilesInVectorStoreBatchRequestOrder right) => left.Equals(right); + public static bool operator !=(InternalListFilesInVectorStoreBatchRequestOrder left, InternalListFilesInVectorStoreBatchRequestOrder right) => !left.Equals(right); + public static implicit operator InternalListFilesInVectorStoreBatchRequestOrder(string value) => new InternalListFilesInVectorStoreBatchRequestOrder(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListFilesInVectorStoreBatchRequestOrder other && Equals(other); - public bool Equals(InternalListFilesInVectorStoreBatchRequestOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListFilesInVectorStoreBatchRequestOrder other && Equals(other); + public bool Equals(InternalListFilesInVectorStoreBatchRequestOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFilesResponseObject.cs b/src/Generated/Models/InternalListFilesResponseObject.cs index 2b578ea1..375daf87 100644 --- a/src/Generated/Models/InternalListFilesResponseObject.cs +++ b/src/Generated/Models/InternalListFilesResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal readonly partial struct InternalListFilesResponseObject : IEquatable { - internal readonly partial struct InternalListFilesResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListFilesResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListFilesResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListFilesResponseObject List { get; } = new InternalListFilesResponseObject(ListValue); - public static bool operator ==(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => !left.Equals(right); - public static implicit operator InternalListFilesResponseObject(string value) => new InternalListFilesResponseObject(value); + public static InternalListFilesResponseObject List { get; } = new InternalListFilesResponseObject(ListValue); + public static bool operator ==(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListFilesResponseObject left, InternalListFilesResponseObject right) => !left.Equals(right); + public static implicit operator InternalListFilesResponseObject(string value) => new InternalListFilesResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListFilesResponseObject other && Equals(other); - public bool Equals(InternalListFilesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListFilesResponseObject other && Equals(other); + public bool Equals(InternalListFilesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.Serialization.cs b/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.Serialization.cs index 9078810a..80732d6c 100644 --- a/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.Serialization.cs +++ b/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.Serialization.cs @@ -8,210 +8,209 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalListFineTuningJobCheckpointsResponse : IJsonModel { - internal partial class InternalListFineTuningJobCheckpointsResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true && Optional.IsDefined(FirstId)) + { + if (FirstId != null) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true && Optional.IsDefined(FirstId)) + else { - if (FirstId != null) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - else - { - writer.WriteNull("first_id"); - } + writer.WriteNull("first_id"); } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true && Optional.IsDefined(LastId)) + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true && Optional.IsDefined(LastId)) + { + if (LastId != null) { - if (LastId != null) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - else - { - writer.WriteNull("last_id"); - } + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + else { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); + writer.WriteNull("last_id"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListFineTuningJobCheckpointsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListFineTuningJobCheckpointsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListFineTuningJobCheckpointsResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support reading '{format}' format."); } - internal static InternalListFineTuningJobCheckpointsResponse DeserializeInternalListFineTuningJobCheckpointsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListFineTuningJobCheckpointsResponse(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList data = default; - InternalListFineTuningJobCheckpointsResponseObject @object = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalListFineTuningJobCheckpointsResponse DeserializeInternalListFineTuningJobCheckpointsResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList data = default; + InternalListFineTuningJobCheckpointsResponseObject @object = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("data"u8)) { - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalFineTuningJobCheckpoint.DeserializeInternalFineTuningJobCheckpoint(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListFineTuningJobCheckpointsResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("first_id"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - firstId = null; - continue; - } - firstId = property.Value.GetString(); - continue; + array.Add(InternalFineTuningJobCheckpoint.DeserializeInternalFineTuningJobCheckpoint(item, options)); } - if (property.NameEquals("last_id"u8)) + data = array; + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalListFineTuningJobCheckpointsResponseObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("first_id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastId = null; - continue; - } - lastId = property.Value.GetString(); + firstId = null; continue; } - if (property.NameEquals("has_more"u8)) + firstId = property.Value.GetString(); + continue; + } + if (property.NameEquals("last_id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - hasMore = property.Value.GetBoolean(); + lastId = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + lastId = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListFineTuningJobCheckpointsResponse( - data, - @object, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("has_more"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support writing '{options.Format}' format."); + hasMore = property.Value.GetBoolean(); + continue; } - } - - InternalListFineTuningJobCheckpointsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListFineTuningJobCheckpointsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListFineTuningJobCheckpointsResponse( + data, + @object, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListFineTuningJobCheckpointsResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListFineTuningJobCheckpointsResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListFineTuningJobCheckpointsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListFineTuningJobCheckpointsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListFineTuningJobCheckpointsResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListFineTuningJobCheckpointsResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListFineTuningJobCheckpointsResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.cs b/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.cs index f96a3d96..6a004ad2 100644 --- a/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.cs +++ b/src/Generated/Models/InternalListFineTuningJobCheckpointsResponse.cs @@ -6,38 +6,37 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalListFineTuningJobCheckpointsResponse { - internal partial class InternalListFineTuningJobCheckpointsResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListFineTuningJobCheckpointsResponse(IEnumerable data, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data.ToList(); + HasMore = hasMore; + } + + internal InternalListFineTuningJobCheckpointsResponse(IReadOnlyList data, InternalListFineTuningJobCheckpointsResponseObject @object, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListFineTuningJobCheckpointsResponse(IEnumerable data, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - - Data = data.ToList(); - HasMore = hasMore; - } - - internal InternalListFineTuningJobCheckpointsResponse(IReadOnlyList data, InternalListFineTuningJobCheckpointsResponseObject @object, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Data = data; - Object = @object; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListFineTuningJobCheckpointsResponse() - { - } - - public IReadOnlyList Data { get; } - public InternalListFineTuningJobCheckpointsResponseObject Object { get; } = InternalListFineTuningJobCheckpointsResponseObject.List; - - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Data = data; + Object = @object; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalListFineTuningJobCheckpointsResponse() + { + } + + public IReadOnlyList Data { get; } + public InternalListFineTuningJobCheckpointsResponseObject Object { get; } = InternalListFineTuningJobCheckpointsResponseObject.List; + + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFineTuningJobCheckpointsResponseObject.cs b/src/Generated/Models/InternalListFineTuningJobCheckpointsResponseObject.cs index 8a9ca04a..03bff39c 100644 --- a/src/Generated/Models/InternalListFineTuningJobCheckpointsResponseObject.cs +++ b/src/Generated/Models/InternalListFineTuningJobCheckpointsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct InternalListFineTuningJobCheckpointsResponseObject : IEquatable { - internal readonly partial struct InternalListFineTuningJobCheckpointsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListFineTuningJobCheckpointsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListFineTuningJobCheckpointsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListFineTuningJobCheckpointsResponseObject List { get; } = new InternalListFineTuningJobCheckpointsResponseObject(ListValue); - public static bool operator ==(InternalListFineTuningJobCheckpointsResponseObject left, InternalListFineTuningJobCheckpointsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListFineTuningJobCheckpointsResponseObject left, InternalListFineTuningJobCheckpointsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListFineTuningJobCheckpointsResponseObject(string value) => new InternalListFineTuningJobCheckpointsResponseObject(value); + public static InternalListFineTuningJobCheckpointsResponseObject List { get; } = new InternalListFineTuningJobCheckpointsResponseObject(ListValue); + public static bool operator ==(InternalListFineTuningJobCheckpointsResponseObject left, InternalListFineTuningJobCheckpointsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListFineTuningJobCheckpointsResponseObject left, InternalListFineTuningJobCheckpointsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListFineTuningJobCheckpointsResponseObject(string value) => new InternalListFineTuningJobCheckpointsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListFineTuningJobCheckpointsResponseObject other && Equals(other); - public bool Equals(InternalListFineTuningJobCheckpointsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListFineTuningJobCheckpointsResponseObject other && Equals(other); + public bool Equals(InternalListFineTuningJobCheckpointsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFineTuningJobEventsResponse.Serialization.cs b/src/Generated/Models/InternalListFineTuningJobEventsResponse.Serialization.cs index 14fbb61f..67003ce9 100644 --- a/src/Generated/Models/InternalListFineTuningJobEventsResponse.Serialization.cs +++ b/src/Generated/Models/InternalListFineTuningJobEventsResponse.Serialization.cs @@ -8,158 +8,157 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalListFineTuningJobEventsResponse : IJsonModel { - internal partial class InternalListFineTuningJobEventsResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListFineTuningJobEventsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListFineTuningJobEventsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListFineTuningJobEventsResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support reading '{format}' format."); } - internal static InternalListFineTuningJobEventsResponse DeserializeInternalListFineTuningJobEventsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListFineTuningJobEventsResponse(document.RootElement, options); + } + + internal static InternalListFineTuningJobEventsResponse DeserializeInternalListFineTuningJobEventsResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool hasMore = default; + IReadOnlyList data = default; + InternalListFineTuningJobEventsResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("has_more"u8)) { - return null; + hasMore = property.Value.GetBoolean(); + continue; } - bool hasMore = default; - IReadOnlyList data = default; - InternalListFineTuningJobEventsResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("has_more"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - hasMore = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(FineTuningJobEvent.DeserializeFineTuningJobEvent(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalListFineTuningJobEventsResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(FineTuningJobEvent.DeserializeFineTuningJobEvent(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListFineTuningJobEventsResponse(hasMore, data, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support writing '{options.Format}' format."); + @object = new InternalListFineTuningJobEventsResponseObject(property.Value.GetString()); + continue; } - } - - InternalListFineTuningJobEventsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListFineTuningJobEventsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListFineTuningJobEventsResponse(hasMore, data, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListFineTuningJobEventsResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListFineTuningJobEventsResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalListFineTuningJobEventsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListFineTuningJobEventsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListFineTuningJobEventsResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListFineTuningJobEventsResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListFineTuningJobEventsResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFineTuningJobEventsResponse.cs b/src/Generated/Models/InternalListFineTuningJobEventsResponse.cs index e8e12b31..cb0a1ad3 100644 --- a/src/Generated/Models/InternalListFineTuningJobEventsResponse.cs +++ b/src/Generated/Models/InternalListFineTuningJobEventsResponse.cs @@ -6,33 +6,32 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalListFineTuningJobEventsResponse { - internal partial class InternalListFineTuningJobEventsResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListFineTuningJobEventsResponse(bool hasMore, IEnumerable data) + { + Argument.AssertNotNull(data, nameof(data)); + + HasMore = hasMore; + Data = data.ToList(); + } + + internal InternalListFineTuningJobEventsResponse(bool hasMore, IReadOnlyList data, InternalListFineTuningJobEventsResponseObject @object, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListFineTuningJobEventsResponse(bool hasMore, IEnumerable data) - { - Argument.AssertNotNull(data, nameof(data)); - - HasMore = hasMore; - Data = data.ToList(); - } - - internal InternalListFineTuningJobEventsResponse(bool hasMore, IReadOnlyList data, InternalListFineTuningJobEventsResponseObject @object, IDictionary serializedAdditionalRawData) - { - HasMore = hasMore; - Data = data; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListFineTuningJobEventsResponse() - { - } - - public bool HasMore { get; } - public IReadOnlyList Data { get; } - public InternalListFineTuningJobEventsResponseObject Object { get; } = InternalListFineTuningJobEventsResponseObject.List; + HasMore = hasMore; + Data = data; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalListFineTuningJobEventsResponse() + { + } + + public bool HasMore { get; } + public IReadOnlyList Data { get; } + public InternalListFineTuningJobEventsResponseObject Object { get; } = InternalListFineTuningJobEventsResponseObject.List; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListFineTuningJobEventsResponseObject.cs b/src/Generated/Models/InternalListFineTuningJobEventsResponseObject.cs index 5f4aa8af..f61cb427 100644 --- a/src/Generated/Models/InternalListFineTuningJobEventsResponseObject.cs +++ b/src/Generated/Models/InternalListFineTuningJobEventsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct InternalListFineTuningJobEventsResponseObject : IEquatable { - internal readonly partial struct InternalListFineTuningJobEventsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListFineTuningJobEventsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListFineTuningJobEventsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListFineTuningJobEventsResponseObject List { get; } = new InternalListFineTuningJobEventsResponseObject(ListValue); - public static bool operator ==(InternalListFineTuningJobEventsResponseObject left, InternalListFineTuningJobEventsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListFineTuningJobEventsResponseObject left, InternalListFineTuningJobEventsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListFineTuningJobEventsResponseObject(string value) => new InternalListFineTuningJobEventsResponseObject(value); + public static InternalListFineTuningJobEventsResponseObject List { get; } = new InternalListFineTuningJobEventsResponseObject(ListValue); + public static bool operator ==(InternalListFineTuningJobEventsResponseObject left, InternalListFineTuningJobEventsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListFineTuningJobEventsResponseObject left, InternalListFineTuningJobEventsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListFineTuningJobEventsResponseObject(string value) => new InternalListFineTuningJobEventsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListFineTuningJobEventsResponseObject other && Equals(other); - public bool Equals(InternalListFineTuningJobEventsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListFineTuningJobEventsResponseObject other && Equals(other); + public bool Equals(InternalListFineTuningJobEventsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListMessagesResponse.Serialization.cs b/src/Generated/Models/InternalListMessagesResponse.Serialization.cs index f91fc9de..eb14fd9d 100644 --- a/src/Generated/Models/InternalListMessagesResponse.Serialization.cs +++ b/src/Generated/Models/InternalListMessagesResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListMessagesResponse : IJsonModel { - internal partial class InternalListMessagesResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListMessagesResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListMessagesResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListMessagesResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support reading '{format}' format."); } - internal static InternalListMessagesResponse DeserializeInternalListMessagesResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListMessagesResponse(document.RootElement, options); + } + + internal static InternalListMessagesResponse DeserializeInternalListMessagesResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalListMessagesResponseObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - return null; + @object = new InternalListMessagesResponseObject(property.Value.GetString()); + continue; } - InternalListMessagesResponseObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListMessagesResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ThreadMessage.DeserializeThreadMessage(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(ThreadMessage.DeserializeThreadMessage(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListMessagesResponse( - @object, - data, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListMessagesResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListMessagesResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListMessagesResponse( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListMessagesResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListMessagesResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListMessagesResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListMessagesResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListMessagesResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListMessagesResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListMessagesResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListMessagesResponse.cs b/src/Generated/Models/InternalListMessagesResponse.cs index 8fd5be21..cd98e4a9 100644 --- a/src/Generated/Models/InternalListMessagesResponse.cs +++ b/src/Generated/Models/InternalListMessagesResponse.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListMessagesResponse { - internal partial class InternalListMessagesResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListMessagesResponse(IEnumerable data, string firstId, string lastId, bool hasMore) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListMessagesResponse(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - internal InternalListMessagesResponse(InternalListMessagesResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListMessagesResponse() - { - } - - public InternalListMessagesResponseObject Object { get; } = InternalListMessagesResponseObject.List; - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } -} + + internal InternalListMessagesResponse(InternalListMessagesResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalListMessagesResponse() + { + } + + public InternalListMessagesResponseObject Object { get; } = InternalListMessagesResponseObject.List; + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListMessagesResponseObject.cs b/src/Generated/Models/InternalListMessagesResponseObject.cs index 44e0d2ab..b4a940ee 100644 --- a/src/Generated/Models/InternalListMessagesResponseObject.cs +++ b/src/Generated/Models/InternalListMessagesResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalListMessagesResponseObject : IEquatable { - internal readonly partial struct InternalListMessagesResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListMessagesResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListMessagesResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListMessagesResponseObject List { get; } = new InternalListMessagesResponseObject(ListValue); - public static bool operator ==(InternalListMessagesResponseObject left, InternalListMessagesResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListMessagesResponseObject left, InternalListMessagesResponseObject right) => !left.Equals(right); - public static implicit operator InternalListMessagesResponseObject(string value) => new InternalListMessagesResponseObject(value); + public static InternalListMessagesResponseObject List { get; } = new InternalListMessagesResponseObject(ListValue); + public static bool operator ==(InternalListMessagesResponseObject left, InternalListMessagesResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListMessagesResponseObject left, InternalListMessagesResponseObject right) => !left.Equals(right); + public static implicit operator InternalListMessagesResponseObject(string value) => new InternalListMessagesResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListMessagesResponseObject other && Equals(other); - public bool Equals(InternalListMessagesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListMessagesResponseObject other && Equals(other); + public bool Equals(InternalListMessagesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListModelsResponseObject.cs b/src/Generated/Models/InternalListModelsResponseObject.cs index 29abbc2c..b43f9e12 100644 --- a/src/Generated/Models/InternalListModelsResponseObject.cs +++ b/src/Generated/Models/InternalListModelsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Models +namespace OpenAI.Models; + +internal readonly partial struct InternalListModelsResponseObject : IEquatable { - internal readonly partial struct InternalListModelsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListModelsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListModelsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListModelsResponseObject List { get; } = new InternalListModelsResponseObject(ListValue); - public static bool operator ==(InternalListModelsResponseObject left, InternalListModelsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListModelsResponseObject left, InternalListModelsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListModelsResponseObject(string value) => new InternalListModelsResponseObject(value); + public static InternalListModelsResponseObject List { get; } = new InternalListModelsResponseObject(ListValue); + public static bool operator ==(InternalListModelsResponseObject left, InternalListModelsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListModelsResponseObject left, InternalListModelsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListModelsResponseObject(string value) => new InternalListModelsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListModelsResponseObject other && Equals(other); - public bool Equals(InternalListModelsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListModelsResponseObject other && Equals(other); + public bool Equals(InternalListModelsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.Serialization.cs b/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.Serialization.cs index bde114de..c91bf450 100644 --- a/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.Serialization.cs +++ b/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.Serialization.cs @@ -8,158 +8,157 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalListPaginatedFineTuningJobsResponse : IJsonModel { - internal partial class InternalListPaginatedFineTuningJobsResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("data") != true) - { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListPaginatedFineTuningJobsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListPaginatedFineTuningJobsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListPaginatedFineTuningJobsResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support reading '{format}' format."); } - internal static InternalListPaginatedFineTuningJobsResponse DeserializeInternalListPaginatedFineTuningJobsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListPaginatedFineTuningJobsResponse(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList data = default; - bool hasMore = default; - InternalListPaginatedFineTuningJobsResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalListPaginatedFineTuningJobsResponse DeserializeInternalListPaginatedFineTuningJobsResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList data = default; + bool hasMore = default; + InternalListPaginatedFineTuningJobsResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("data"u8)) { - if (property.NameEquals("data"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(FineTuningJob.DeserializeFineTuningJob(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalListPaginatedFineTuningJobsResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(FineTuningJob.DeserializeFineTuningJob(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListPaginatedFineTuningJobsResponse(data, hasMore, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("has_more"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support writing '{options.Format}' format."); + hasMore = property.Value.GetBoolean(); + continue; } - } - - InternalListPaginatedFineTuningJobsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) + { + @object = new InternalListPaginatedFineTuningJobsResponseObject(property.Value.GetString()); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListPaginatedFineTuningJobsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListPaginatedFineTuningJobsResponse(data, hasMore, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListPaginatedFineTuningJobsResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListPaginatedFineTuningJobsResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListPaginatedFineTuningJobsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListPaginatedFineTuningJobsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListPaginatedFineTuningJobsResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListPaginatedFineTuningJobsResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListPaginatedFineTuningJobsResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.cs b/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.cs index 3789ce4e..9764ac24 100644 --- a/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.cs +++ b/src/Generated/Models/InternalListPaginatedFineTuningJobsResponse.cs @@ -6,33 +6,32 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class InternalListPaginatedFineTuningJobsResponse { - internal partial class InternalListPaginatedFineTuningJobsResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListPaginatedFineTuningJobsResponse(IEnumerable data, bool hasMore) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data.ToList(); + HasMore = hasMore; + } + + internal InternalListPaginatedFineTuningJobsResponse(IReadOnlyList data, bool hasMore, InternalListPaginatedFineTuningJobsResponseObject @object, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListPaginatedFineTuningJobsResponse(IEnumerable data, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - - Data = data.ToList(); - HasMore = hasMore; - } - - internal InternalListPaginatedFineTuningJobsResponse(IReadOnlyList data, bool hasMore, InternalListPaginatedFineTuningJobsResponseObject @object, IDictionary serializedAdditionalRawData) - { - Data = data; - HasMore = hasMore; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListPaginatedFineTuningJobsResponse() - { - } - - public IReadOnlyList Data { get; } - public bool HasMore { get; } - public InternalListPaginatedFineTuningJobsResponseObject Object { get; } = InternalListPaginatedFineTuningJobsResponseObject.List; + Data = data; + HasMore = hasMore; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalListPaginatedFineTuningJobsResponse() + { + } + + public IReadOnlyList Data { get; } + public bool HasMore { get; } + public InternalListPaginatedFineTuningJobsResponseObject Object { get; } = InternalListPaginatedFineTuningJobsResponseObject.List; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListPaginatedFineTuningJobsResponseObject.cs b/src/Generated/Models/InternalListPaginatedFineTuningJobsResponseObject.cs index b9dcd5fb..34ab4d0c 100644 --- a/src/Generated/Models/InternalListPaginatedFineTuningJobsResponseObject.cs +++ b/src/Generated/Models/InternalListPaginatedFineTuningJobsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal readonly partial struct InternalListPaginatedFineTuningJobsResponseObject : IEquatable { - internal readonly partial struct InternalListPaginatedFineTuningJobsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListPaginatedFineTuningJobsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListPaginatedFineTuningJobsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListPaginatedFineTuningJobsResponseObject List { get; } = new InternalListPaginatedFineTuningJobsResponseObject(ListValue); - public static bool operator ==(InternalListPaginatedFineTuningJobsResponseObject left, InternalListPaginatedFineTuningJobsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListPaginatedFineTuningJobsResponseObject left, InternalListPaginatedFineTuningJobsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListPaginatedFineTuningJobsResponseObject(string value) => new InternalListPaginatedFineTuningJobsResponseObject(value); + public static InternalListPaginatedFineTuningJobsResponseObject List { get; } = new InternalListPaginatedFineTuningJobsResponseObject(ListValue); + public static bool operator ==(InternalListPaginatedFineTuningJobsResponseObject left, InternalListPaginatedFineTuningJobsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListPaginatedFineTuningJobsResponseObject left, InternalListPaginatedFineTuningJobsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListPaginatedFineTuningJobsResponseObject(string value) => new InternalListPaginatedFineTuningJobsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListPaginatedFineTuningJobsResponseObject other && Equals(other); - public bool Equals(InternalListPaginatedFineTuningJobsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListPaginatedFineTuningJobsResponseObject other && Equals(other); + public bool Equals(InternalListPaginatedFineTuningJobsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListRunStepsResponse.Serialization.cs b/src/Generated/Models/InternalListRunStepsResponse.Serialization.cs index 74e2033a..d6c2e3c2 100644 --- a/src/Generated/Models/InternalListRunStepsResponse.Serialization.cs +++ b/src/Generated/Models/InternalListRunStepsResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListRunStepsResponse : IJsonModel { - internal partial class InternalListRunStepsResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListRunStepsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListRunStepsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListRunStepsResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support reading '{format}' format."); } - internal static InternalListRunStepsResponse DeserializeInternalListRunStepsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListRunStepsResponse(document.RootElement, options); + } + + internal static InternalListRunStepsResponse DeserializeInternalListRunStepsResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalListRunStepsResponseObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - return null; + @object = new InternalListRunStepsResponseObject(property.Value.GetString()); + continue; } - InternalListRunStepsResponseObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListRunStepsResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStep.DeserializeRunStep(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(RunStep.DeserializeRunStep(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListRunStepsResponse( - @object, - data, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListRunStepsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListRunStepsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListRunStepsResponse( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListRunStepsResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListRunStepsResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListRunStepsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListRunStepsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListRunStepsResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListRunStepsResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListRunStepsResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListRunStepsResponse.cs b/src/Generated/Models/InternalListRunStepsResponse.cs index 4ef3eb22..dcf1b79d 100644 --- a/src/Generated/Models/InternalListRunStepsResponse.cs +++ b/src/Generated/Models/InternalListRunStepsResponse.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListRunStepsResponse { - internal partial class InternalListRunStepsResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListRunStepsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListRunStepsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - internal InternalListRunStepsResponse(InternalListRunStepsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListRunStepsResponse() - { - } - - public InternalListRunStepsResponseObject Object { get; } = InternalListRunStepsResponseObject.List; - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } -} + + internal InternalListRunStepsResponse(InternalListRunStepsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalListRunStepsResponse() + { + } + + public InternalListRunStepsResponseObject Object { get; } = InternalListRunStepsResponseObject.List; + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListRunStepsResponseObject.cs b/src/Generated/Models/InternalListRunStepsResponseObject.cs index c554f8ae..9ee01553 100644 --- a/src/Generated/Models/InternalListRunStepsResponseObject.cs +++ b/src/Generated/Models/InternalListRunStepsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalListRunStepsResponseObject : IEquatable { - internal readonly partial struct InternalListRunStepsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListRunStepsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListRunStepsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListRunStepsResponseObject List { get; } = new InternalListRunStepsResponseObject(ListValue); - public static bool operator ==(InternalListRunStepsResponseObject left, InternalListRunStepsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListRunStepsResponseObject left, InternalListRunStepsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListRunStepsResponseObject(string value) => new InternalListRunStepsResponseObject(value); + public static InternalListRunStepsResponseObject List { get; } = new InternalListRunStepsResponseObject(ListValue); + public static bool operator ==(InternalListRunStepsResponseObject left, InternalListRunStepsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListRunStepsResponseObject left, InternalListRunStepsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListRunStepsResponseObject(string value) => new InternalListRunStepsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListRunStepsResponseObject other && Equals(other); - public bool Equals(InternalListRunStepsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListRunStepsResponseObject other && Equals(other); + public bool Equals(InternalListRunStepsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListRunsResponse.Serialization.cs b/src/Generated/Models/InternalListRunsResponse.Serialization.cs index 049905e5..a0cb00fe 100644 --- a/src/Generated/Models/InternalListRunsResponse.Serialization.cs +++ b/src/Generated/Models/InternalListRunsResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListRunsResponse : IJsonModel { - internal partial class InternalListRunsResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListRunsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListRunsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListRunsResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support reading '{format}' format."); } - internal static InternalListRunsResponse DeserializeInternalListRunsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListRunsResponse(document.RootElement, options); + } + + internal static InternalListRunsResponse DeserializeInternalListRunsResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalListRunsResponseObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - return null; + @object = new InternalListRunsResponseObject(property.Value.GetString()); + continue; } - InternalListRunsResponseObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListRunsResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ThreadRun.DeserializeThreadRun(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(ThreadRun.DeserializeThreadRun(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListRunsResponse( - @object, - data, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListRunsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListRunsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListRunsResponse( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListRunsResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListRunsResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListRunsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListRunsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListRunsResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListRunsResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListRunsResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListRunsResponse.cs b/src/Generated/Models/InternalListRunsResponse.cs index 4f10784e..702a2b57 100644 --- a/src/Generated/Models/InternalListRunsResponse.cs +++ b/src/Generated/Models/InternalListRunsResponse.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListRunsResponse { - internal partial class InternalListRunsResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListRunsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListRunsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - internal InternalListRunsResponse(InternalListRunsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListRunsResponse() - { - } - - public InternalListRunsResponseObject Object { get; } = InternalListRunsResponseObject.List; - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } -} + + internal InternalListRunsResponse(InternalListRunsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalListRunsResponse() + { + } + + public InternalListRunsResponseObject Object { get; } = InternalListRunsResponseObject.List; + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListRunsResponseObject.cs b/src/Generated/Models/InternalListRunsResponseObject.cs index 68d723f1..3a91667d 100644 --- a/src/Generated/Models/InternalListRunsResponseObject.cs +++ b/src/Generated/Models/InternalListRunsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalListRunsResponseObject : IEquatable { - internal readonly partial struct InternalListRunsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListRunsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListRunsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListRunsResponseObject List { get; } = new InternalListRunsResponseObject(ListValue); - public static bool operator ==(InternalListRunsResponseObject left, InternalListRunsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListRunsResponseObject left, InternalListRunsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListRunsResponseObject(string value) => new InternalListRunsResponseObject(value); + public static InternalListRunsResponseObject List { get; } = new InternalListRunsResponseObject(ListValue); + public static bool operator ==(InternalListRunsResponseObject left, InternalListRunsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListRunsResponseObject left, InternalListRunsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListRunsResponseObject(string value) => new InternalListRunsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListRunsResponseObject other && Equals(other); - public bool Equals(InternalListRunsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListRunsResponseObject other && Equals(other); + public bool Equals(InternalListRunsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListThreadsResponse.Serialization.cs b/src/Generated/Models/InternalListThreadsResponse.Serialization.cs index 9a4ec199..6e7d886a 100644 --- a/src/Generated/Models/InternalListThreadsResponse.Serialization.cs +++ b/src/Generated/Models/InternalListThreadsResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListThreadsResponse : IJsonModel { - internal partial class InternalListThreadsResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListThreadsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListThreadsResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListThreadsResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support reading '{format}' format."); } - internal static InternalListThreadsResponse DeserializeInternalListThreadsResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListThreadsResponse(document.RootElement, options); + } + + internal static InternalListThreadsResponse DeserializeInternalListThreadsResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalListThreadsResponseObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - return null; + @object = new InternalListThreadsResponseObject(property.Value.GetString()); + continue; } - InternalListThreadsResponseObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListThreadsResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(AssistantThread.DeserializeAssistantThread(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(AssistantThread.DeserializeAssistantThread(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListThreadsResponse( - @object, - data, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListThreadsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListThreadsResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListThreadsResponse( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListThreadsResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListThreadsResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListThreadsResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListThreadsResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListThreadsResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListThreadsResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListThreadsResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListThreadsResponse.cs b/src/Generated/Models/InternalListThreadsResponse.cs index 0424339f..7cbb1ebb 100644 --- a/src/Generated/Models/InternalListThreadsResponse.cs +++ b/src/Generated/Models/InternalListThreadsResponse.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalListThreadsResponse { - internal partial class InternalListThreadsResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListThreadsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListThreadsResponse(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - internal InternalListThreadsResponse(InternalListThreadsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListThreadsResponse() - { - } - - public InternalListThreadsResponseObject Object { get; } = InternalListThreadsResponseObject.List; - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } -} + + internal InternalListThreadsResponse(InternalListThreadsResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalListThreadsResponse() + { + } + + public InternalListThreadsResponseObject Object { get; } = InternalListThreadsResponseObject.List; + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListThreadsResponseObject.cs b/src/Generated/Models/InternalListThreadsResponseObject.cs index 8fc2b64b..6d3f0f8d 100644 --- a/src/Generated/Models/InternalListThreadsResponseObject.cs +++ b/src/Generated/Models/InternalListThreadsResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalListThreadsResponseObject : IEquatable { - internal readonly partial struct InternalListThreadsResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListThreadsResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListThreadsResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListThreadsResponseObject List { get; } = new InternalListThreadsResponseObject(ListValue); - public static bool operator ==(InternalListThreadsResponseObject left, InternalListThreadsResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListThreadsResponseObject left, InternalListThreadsResponseObject right) => !left.Equals(right); - public static implicit operator InternalListThreadsResponseObject(string value) => new InternalListThreadsResponseObject(value); + public static InternalListThreadsResponseObject List { get; } = new InternalListThreadsResponseObject(ListValue); + public static bool operator ==(InternalListThreadsResponseObject left, InternalListThreadsResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListThreadsResponseObject left, InternalListThreadsResponseObject right) => !left.Equals(right); + public static implicit operator InternalListThreadsResponseObject(string value) => new InternalListThreadsResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListThreadsResponseObject other && Equals(other); - public bool Equals(InternalListThreadsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListThreadsResponseObject other && Equals(other); + public bool Equals(InternalListThreadsResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListVectorStoreFilesResponse.Serialization.cs b/src/Generated/Models/InternalListVectorStoreFilesResponse.Serialization.cs index 3b5f44ef..28956635 100644 --- a/src/Generated/Models/InternalListVectorStoreFilesResponse.Serialization.cs +++ b/src/Generated/Models/InternalListVectorStoreFilesResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalListVectorStoreFilesResponse : IJsonModel { - internal partial class InternalListVectorStoreFilesResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListVectorStoreFilesResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListVectorStoreFilesResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListVectorStoreFilesResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support reading '{format}' format."); } - internal static InternalListVectorStoreFilesResponse DeserializeInternalListVectorStoreFilesResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListVectorStoreFilesResponse(document.RootElement, options); + } + + internal static InternalListVectorStoreFilesResponse DeserializeInternalListVectorStoreFilesResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalListVectorStoreFilesResponseObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - return null; + @object = new InternalListVectorStoreFilesResponseObject(property.Value.GetString()); + continue; } - InternalListVectorStoreFilesResponseObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListVectorStoreFilesResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStoreFileAssociation.DeserializeVectorStoreFileAssociation(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(VectorStoreFileAssociation.DeserializeVectorStoreFileAssociation(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListVectorStoreFilesResponse( - @object, - data, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListVectorStoreFilesResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListVectorStoreFilesResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListVectorStoreFilesResponse( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListVectorStoreFilesResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListVectorStoreFilesResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListVectorStoreFilesResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListVectorStoreFilesResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListVectorStoreFilesResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListVectorStoreFilesResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListVectorStoreFilesResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListVectorStoreFilesResponse.cs b/src/Generated/Models/InternalListVectorStoreFilesResponse.cs index cef50209..f280112f 100644 --- a/src/Generated/Models/InternalListVectorStoreFilesResponse.cs +++ b/src/Generated/Models/InternalListVectorStoreFilesResponse.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalListVectorStoreFilesResponse { - internal partial class InternalListVectorStoreFilesResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListVectorStoreFilesResponse(IEnumerable data, string firstId, string lastId, bool hasMore) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListVectorStoreFilesResponse(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - internal InternalListVectorStoreFilesResponse(InternalListVectorStoreFilesResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListVectorStoreFilesResponse() - { - } - - public InternalListVectorStoreFilesResponseObject Object { get; } = InternalListVectorStoreFilesResponseObject.List; - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } -} + + internal InternalListVectorStoreFilesResponse(InternalListVectorStoreFilesResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalListVectorStoreFilesResponse() + { + } + + public InternalListVectorStoreFilesResponseObject Object { get; } = InternalListVectorStoreFilesResponseObject.List; + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListVectorStoreFilesResponseObject.cs b/src/Generated/Models/InternalListVectorStoreFilesResponseObject.cs index bc320af3..5746d452 100644 --- a/src/Generated/Models/InternalListVectorStoreFilesResponseObject.cs +++ b/src/Generated/Models/InternalListVectorStoreFilesResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalListVectorStoreFilesResponseObject : IEquatable { - internal readonly partial struct InternalListVectorStoreFilesResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListVectorStoreFilesResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListVectorStoreFilesResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListVectorStoreFilesResponseObject List { get; } = new InternalListVectorStoreFilesResponseObject(ListValue); - public static bool operator ==(InternalListVectorStoreFilesResponseObject left, InternalListVectorStoreFilesResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListVectorStoreFilesResponseObject left, InternalListVectorStoreFilesResponseObject right) => !left.Equals(right); - public static implicit operator InternalListVectorStoreFilesResponseObject(string value) => new InternalListVectorStoreFilesResponseObject(value); + public static InternalListVectorStoreFilesResponseObject List { get; } = new InternalListVectorStoreFilesResponseObject(ListValue); + public static bool operator ==(InternalListVectorStoreFilesResponseObject left, InternalListVectorStoreFilesResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListVectorStoreFilesResponseObject left, InternalListVectorStoreFilesResponseObject right) => !left.Equals(right); + public static implicit operator InternalListVectorStoreFilesResponseObject(string value) => new InternalListVectorStoreFilesResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListVectorStoreFilesResponseObject other && Equals(other); - public bool Equals(InternalListVectorStoreFilesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListVectorStoreFilesResponseObject other && Equals(other); + public bool Equals(InternalListVectorStoreFilesResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListVectorStoresResponse.Serialization.cs b/src/Generated/Models/InternalListVectorStoresResponse.Serialization.cs index e01ffb73..e6c4574d 100644 --- a/src/Generated/Models/InternalListVectorStoresResponse.Serialization.cs +++ b/src/Generated/Models/InternalListVectorStoresResponse.Serialization.cs @@ -8,186 +8,185 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalListVectorStoresResponse : IJsonModel { - internal partial class InternalListVectorStoresResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("data") != true) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("data") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) + { + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + } + if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) + { + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + } + if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) + { + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("data"u8); - writer.WriteStartArray(); - foreach (var item in Data) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("first_id") != true) - { - writer.WritePropertyName("first_id"u8); - writer.WriteStringValue(FirstId); - } - if (SerializedAdditionalRawData?.ContainsKey("last_id") != true) - { - writer.WritePropertyName("last_id"u8); - writer.WriteStringValue(LastId); - } - if (SerializedAdditionalRawData?.ContainsKey("has_more") != true) - { - writer.WritePropertyName("has_more"u8); - writer.WriteBooleanValue(HasMore); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalListVectorStoresResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalListVectorStoresResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalListVectorStoresResponse(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support reading '{format}' format."); } - internal static InternalListVectorStoresResponse DeserializeInternalListVectorStoresResponse(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalListVectorStoresResponse(document.RootElement, options); + } + + internal static InternalListVectorStoresResponse DeserializeInternalListVectorStoresResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalListVectorStoresResponseObject @object = default; + IReadOnlyList data = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("object"u8)) { - return null; + @object = new InternalListVectorStoresResponseObject(property.Value.GetString()); + continue; } - InternalListVectorStoresResponseObject @object = default; - IReadOnlyList data = default; - string firstId = default; - string lastId = default; - bool hasMore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("data"u8)) { - if (property.NameEquals("object"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - @object = new InternalListVectorStoresResponseObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("data"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(VectorStore.DeserializeVectorStore(item, options)); - } - data = array; - continue; - } - if (property.NameEquals("first_id"u8)) - { - firstId = property.Value.GetString(); - continue; - } - if (property.NameEquals("last_id"u8)) - { - lastId = property.Value.GetString(); - continue; - } - if (property.NameEquals("has_more"u8)) - { - hasMore = property.Value.GetBoolean(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(VectorStore.DeserializeVectorStore(item, options)); } + data = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalListVectorStoresResponse( - @object, - data, - firstId, - lastId, - hasMore, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("first_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support writing '{options.Format}' format."); + firstId = property.Value.GetString(); + continue; } - } - - InternalListVectorStoresResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("last_id"u8)) + { + lastId = property.Value.GetString(); + continue; + } + if (property.NameEquals("has_more"u8)) + { + hasMore = property.Value.GetBoolean(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalListVectorStoresResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalListVectorStoresResponse( + @object, + data, + firstId, + lastId, + hasMore, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalListVectorStoresResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalListVectorStoresResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support writing '{options.Format}' format."); } + } + + InternalListVectorStoresResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalListVectorStoresResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalListVectorStoresResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalListVectorStoresResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalListVectorStoresResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListVectorStoresResponse.cs b/src/Generated/Models/InternalListVectorStoresResponse.cs index 98135e24..8b06d946 100644 --- a/src/Generated/Models/InternalListVectorStoresResponse.cs +++ b/src/Generated/Models/InternalListVectorStoresResponse.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalListVectorStoresResponse { - internal partial class InternalListVectorStoresResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalListVectorStoresResponse(IEnumerable data, string firstId, string lastId, bool hasMore) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalListVectorStoresResponse(IEnumerable data, string firstId, string lastId, bool hasMore) - { - Argument.AssertNotNull(data, nameof(data)); - Argument.AssertNotNull(firstId, nameof(firstId)); - Argument.AssertNotNull(lastId, nameof(lastId)); - - Data = data.ToList(); - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - } - - internal InternalListVectorStoresResponse(InternalListVectorStoresResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) - { - Object = @object; - Data = data; - FirstId = firstId; - LastId = lastId; - HasMore = hasMore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalListVectorStoresResponse() - { - } - - public InternalListVectorStoresResponseObject Object { get; } = InternalListVectorStoresResponseObject.List; - - public IReadOnlyList Data { get; } - public string FirstId { get; } - public string LastId { get; } - public bool HasMore { get; } + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(firstId, nameof(firstId)); + Argument.AssertNotNull(lastId, nameof(lastId)); + + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; } -} + + internal InternalListVectorStoresResponse(InternalListVectorStoresResponseObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + { + Object = @object; + Data = data; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalListVectorStoresResponse() + { + } + + public InternalListVectorStoresResponseObject Object { get; } = InternalListVectorStoresResponseObject.List; + + public IReadOnlyList Data { get; } + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalListVectorStoresResponseObject.cs b/src/Generated/Models/InternalListVectorStoresResponseObject.cs index 1f3c8a3f..8de4c45f 100644 --- a/src/Generated/Models/InternalListVectorStoresResponseObject.cs +++ b/src/Generated/Models/InternalListVectorStoresResponseObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalListVectorStoresResponseObject : IEquatable { - internal readonly partial struct InternalListVectorStoresResponseObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalListVectorStoresResponseObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalListVectorStoresResponseObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ListValue = "list"; + private const string ListValue = "list"; - public static InternalListVectorStoresResponseObject List { get; } = new InternalListVectorStoresResponseObject(ListValue); - public static bool operator ==(InternalListVectorStoresResponseObject left, InternalListVectorStoresResponseObject right) => left.Equals(right); - public static bool operator !=(InternalListVectorStoresResponseObject left, InternalListVectorStoresResponseObject right) => !left.Equals(right); - public static implicit operator InternalListVectorStoresResponseObject(string value) => new InternalListVectorStoresResponseObject(value); + public static InternalListVectorStoresResponseObject List { get; } = new InternalListVectorStoresResponseObject(ListValue); + public static bool operator ==(InternalListVectorStoresResponseObject left, InternalListVectorStoresResponseObject right) => left.Equals(right); + public static bool operator !=(InternalListVectorStoresResponseObject left, InternalListVectorStoresResponseObject right) => !left.Equals(right); + public static implicit operator InternalListVectorStoresResponseObject(string value) => new InternalListVectorStoresResponseObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListVectorStoresResponseObject other && Equals(other); - public bool Equals(InternalListVectorStoresResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalListVectorStoresResponseObject other && Equals(other); + public bool Equals(InternalListVectorStoresResponseObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentImageFileObjectImageFileDetail.cs b/src/Generated/Models/InternalMessageContentImageFileObjectImageFileDetail.cs index c6099b4c..102fa803 100644 --- a/src/Generated/Models/InternalMessageContentImageFileObjectImageFileDetail.cs +++ b/src/Generated/Models/InternalMessageContentImageFileObjectImageFileDetail.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageContentImageFileObjectImageFileDetail : IEquatable { - internal readonly partial struct InternalMessageContentImageFileObjectImageFileDetail : IEquatable + private readonly string _value; + + public InternalMessageContentImageFileObjectImageFileDetail(string value) { - private readonly string _value; - - public InternalMessageContentImageFileObjectImageFileDetail(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string LowValue = "low"; - private const string HighValue = "high"; - - public static InternalMessageContentImageFileObjectImageFileDetail Auto { get; } = new InternalMessageContentImageFileObjectImageFileDetail(AutoValue); - public static InternalMessageContentImageFileObjectImageFileDetail Low { get; } = new InternalMessageContentImageFileObjectImageFileDetail(LowValue); - public static InternalMessageContentImageFileObjectImageFileDetail High { get; } = new InternalMessageContentImageFileObjectImageFileDetail(HighValue); - public static bool operator ==(InternalMessageContentImageFileObjectImageFileDetail left, InternalMessageContentImageFileObjectImageFileDetail right) => left.Equals(right); - public static bool operator !=(InternalMessageContentImageFileObjectImageFileDetail left, InternalMessageContentImageFileObjectImageFileDetail right) => !left.Equals(right); - public static implicit operator InternalMessageContentImageFileObjectImageFileDetail(string value) => new InternalMessageContentImageFileObjectImageFileDetail(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageContentImageFileObjectImageFileDetail other && Equals(other); - public bool Equals(InternalMessageContentImageFileObjectImageFileDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AutoValue = "auto"; + private const string LowValue = "low"; + private const string HighValue = "high"; + + public static InternalMessageContentImageFileObjectImageFileDetail Auto { get; } = new InternalMessageContentImageFileObjectImageFileDetail(AutoValue); + public static InternalMessageContentImageFileObjectImageFileDetail Low { get; } = new InternalMessageContentImageFileObjectImageFileDetail(LowValue); + public static InternalMessageContentImageFileObjectImageFileDetail High { get; } = new InternalMessageContentImageFileObjectImageFileDetail(HighValue); + public static bool operator ==(InternalMessageContentImageFileObjectImageFileDetail left, InternalMessageContentImageFileObjectImageFileDetail right) => left.Equals(right); + public static bool operator !=(InternalMessageContentImageFileObjectImageFileDetail left, InternalMessageContentImageFileObjectImageFileDetail right) => !left.Equals(right); + public static implicit operator InternalMessageContentImageFileObjectImageFileDetail(string value) => new InternalMessageContentImageFileObjectImageFileDetail(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageContentImageFileObjectImageFileDetail other && Equals(other); + public bool Equals(InternalMessageContentImageFileObjectImageFileDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentImageFileObjectType.cs b/src/Generated/Models/InternalMessageContentImageFileObjectType.cs index 716165ec..3d34003b 100644 --- a/src/Generated/Models/InternalMessageContentImageFileObjectType.cs +++ b/src/Generated/Models/InternalMessageContentImageFileObjectType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageContentImageFileObjectType : IEquatable { - internal readonly partial struct InternalMessageContentImageFileObjectType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageContentImageFileObjectType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageContentImageFileObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ImageFileValue = "image_file"; + private const string ImageFileValue = "image_file"; - public static InternalMessageContentImageFileObjectType ImageFile { get; } = new InternalMessageContentImageFileObjectType(ImageFileValue); - public static bool operator ==(InternalMessageContentImageFileObjectType left, InternalMessageContentImageFileObjectType right) => left.Equals(right); - public static bool operator !=(InternalMessageContentImageFileObjectType left, InternalMessageContentImageFileObjectType right) => !left.Equals(right); - public static implicit operator InternalMessageContentImageFileObjectType(string value) => new InternalMessageContentImageFileObjectType(value); + public static InternalMessageContentImageFileObjectType ImageFile { get; } = new InternalMessageContentImageFileObjectType(ImageFileValue); + public static bool operator ==(InternalMessageContentImageFileObjectType left, InternalMessageContentImageFileObjectType right) => left.Equals(right); + public static bool operator !=(InternalMessageContentImageFileObjectType left, InternalMessageContentImageFileObjectType right) => !left.Equals(right); + public static implicit operator InternalMessageContentImageFileObjectType(string value) => new InternalMessageContentImageFileObjectType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageContentImageFileObjectType other && Equals(other); - public bool Equals(InternalMessageContentImageFileObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageContentImageFileObjectType other && Equals(other); + public bool Equals(InternalMessageContentImageFileObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.Serialization.cs b/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.Serialization.cs index 37672667..c99ed367 100644 --- a/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentImageUrlObjectImageUrl : IJsonModel { - internal partial class InternalMessageContentImageUrlObjectImageUrl : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("url") != true) - { - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url.AbsoluteUri); - } - if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) - { - writer.WritePropertyName("detail"u8); - writer.WriteStringValue(Detail); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("url") != true) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageContentImageUrlObjectImageUrl IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageContentImageUrlObjectImageUrl IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentImageUrlObjectImageUrl(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support reading '{format}' format."); } - internal static InternalMessageContentImageUrlObjectImageUrl DeserializeInternalMessageContentImageUrlObjectImageUrl(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentImageUrlObjectImageUrl(document.RootElement, options); + } + + internal static InternalMessageContentImageUrlObjectImageUrl DeserializeInternalMessageContentImageUrlObjectImageUrl(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri url = default; + string detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) { - return null; + url = new Uri(property.Value.GetString()); + continue; } - Uri url = default; - string detail = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("detail"u8)) { - if (property.NameEquals("url"u8)) - { - url = new Uri(property.Value.GetString()); - continue; - } - if (property.NameEquals("detail"u8)) - { - detail = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + detail = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentImageUrlObjectImageUrl(url, detail, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageContentImageUrlObjectImageUrl(url, detail, serializedAdditionalRawData); + } - InternalMessageContentImageUrlObjectImageUrl IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentImageUrlObjectImageUrl(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageContentImageUrlObjectImageUrl IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageContentImageUrlObjectImageUrl FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentImageUrlObjectImageUrl(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentImageUrlObjectImageUrl(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentImageUrlObjectImageUrl)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageContentImageUrlObjectImageUrl FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentImageUrlObjectImageUrl(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.cs b/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.cs index ec3f49b7..d6d9fa93 100644 --- a/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.cs +++ b/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrl.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentImageUrlObjectImageUrl { - internal partial class InternalMessageContentImageUrlObjectImageUrl + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalMessageContentImageUrlObjectImageUrl(Uri url) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + internal InternalMessageContentImageUrlObjectImageUrl(Uri url, string detail, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalMessageContentImageUrlObjectImageUrl(Uri url) - { - Argument.AssertNotNull(url, nameof(url)); - - Url = url; - } - - internal InternalMessageContentImageUrlObjectImageUrl(Uri url, string detail, IDictionary serializedAdditionalRawData) - { - Url = url; - Detail = detail; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalMessageContentImageUrlObjectImageUrl() - { - } - - public Uri Url { get; set; } + Url = url; + Detail = detail; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalMessageContentImageUrlObjectImageUrl() + { + } + + public Uri Url { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrlDetail.cs b/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrlDetail.cs index 1ae9181d..a36adc69 100644 --- a/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrlDetail.cs +++ b/src/Generated/Models/InternalMessageContentImageUrlObjectImageUrlDetail.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageContentImageUrlObjectImageUrlDetail : IEquatable { - internal readonly partial struct InternalMessageContentImageUrlObjectImageUrlDetail : IEquatable + private readonly string _value; + + public InternalMessageContentImageUrlObjectImageUrlDetail(string value) { - private readonly string _value; - - public InternalMessageContentImageUrlObjectImageUrlDetail(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string LowValue = "low"; - private const string HighValue = "high"; - - public static InternalMessageContentImageUrlObjectImageUrlDetail Auto { get; } = new InternalMessageContentImageUrlObjectImageUrlDetail(AutoValue); - public static InternalMessageContentImageUrlObjectImageUrlDetail Low { get; } = new InternalMessageContentImageUrlObjectImageUrlDetail(LowValue); - public static InternalMessageContentImageUrlObjectImageUrlDetail High { get; } = new InternalMessageContentImageUrlObjectImageUrlDetail(HighValue); - public static bool operator ==(InternalMessageContentImageUrlObjectImageUrlDetail left, InternalMessageContentImageUrlObjectImageUrlDetail right) => left.Equals(right); - public static bool operator !=(InternalMessageContentImageUrlObjectImageUrlDetail left, InternalMessageContentImageUrlObjectImageUrlDetail right) => !left.Equals(right); - public static implicit operator InternalMessageContentImageUrlObjectImageUrlDetail(string value) => new InternalMessageContentImageUrlObjectImageUrlDetail(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageContentImageUrlObjectImageUrlDetail other && Equals(other); - public bool Equals(InternalMessageContentImageUrlObjectImageUrlDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AutoValue = "auto"; + private const string LowValue = "low"; + private const string HighValue = "high"; + + public static InternalMessageContentImageUrlObjectImageUrlDetail Auto { get; } = new InternalMessageContentImageUrlObjectImageUrlDetail(AutoValue); + public static InternalMessageContentImageUrlObjectImageUrlDetail Low { get; } = new InternalMessageContentImageUrlObjectImageUrlDetail(LowValue); + public static InternalMessageContentImageUrlObjectImageUrlDetail High { get; } = new InternalMessageContentImageUrlObjectImageUrlDetail(HighValue); + public static bool operator ==(InternalMessageContentImageUrlObjectImageUrlDetail left, InternalMessageContentImageUrlObjectImageUrlDetail right) => left.Equals(right); + public static bool operator !=(InternalMessageContentImageUrlObjectImageUrlDetail left, InternalMessageContentImageUrlObjectImageUrlDetail right) => !left.Equals(right); + public static implicit operator InternalMessageContentImageUrlObjectImageUrlDetail(string value) => new InternalMessageContentImageUrlObjectImageUrlDetail(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageContentImageUrlObjectImageUrlDetail other && Equals(other); + public bool Equals(InternalMessageContentImageUrlObjectImageUrlDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentImageUrlObjectType.cs b/src/Generated/Models/InternalMessageContentImageUrlObjectType.cs index 74139876..de4fc2fa 100644 --- a/src/Generated/Models/InternalMessageContentImageUrlObjectType.cs +++ b/src/Generated/Models/InternalMessageContentImageUrlObjectType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageContentImageUrlObjectType : IEquatable { - internal readonly partial struct InternalMessageContentImageUrlObjectType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageContentImageUrlObjectType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageContentImageUrlObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ImageUrlValue = "image_url"; + private const string ImageUrlValue = "image_url"; - public static InternalMessageContentImageUrlObjectType ImageUrl { get; } = new InternalMessageContentImageUrlObjectType(ImageUrlValue); - public static bool operator ==(InternalMessageContentImageUrlObjectType left, InternalMessageContentImageUrlObjectType right) => left.Equals(right); - public static bool operator !=(InternalMessageContentImageUrlObjectType left, InternalMessageContentImageUrlObjectType right) => !left.Equals(right); - public static implicit operator InternalMessageContentImageUrlObjectType(string value) => new InternalMessageContentImageUrlObjectType(value); + public static InternalMessageContentImageUrlObjectType ImageUrl { get; } = new InternalMessageContentImageUrlObjectType(ImageUrlValue); + public static bool operator ==(InternalMessageContentImageUrlObjectType left, InternalMessageContentImageUrlObjectType right) => left.Equals(right); + public static bool operator !=(InternalMessageContentImageUrlObjectType left, InternalMessageContentImageUrlObjectType right) => !left.Equals(right); + public static implicit operator InternalMessageContentImageUrlObjectType(string value) => new InternalMessageContentImageUrlObjectType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageContentImageUrlObjectType other && Equals(other); - public bool Equals(InternalMessageContentImageUrlObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageContentImageUrlObjectType other && Equals(other); + public bool Equals(InternalMessageContentImageUrlObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.Serialization.cs b/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.Serialization.cs index a05a6738..3bdf46fb 100644 --- a/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentItemFileObjectImageFile : IJsonModel { - internal partial class InternalMessageContentItemFileObjectImageFile : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) - { - writer.WritePropertyName("detail"u8); - writer.WriteStringValue(Detail); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageContentItemFileObjectImageFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageContentItemFileObjectImageFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentItemFileObjectImageFile(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support reading '{format}' format."); } - internal static InternalMessageContentItemFileObjectImageFile DeserializeInternalMessageContentItemFileObjectImageFile(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentItemFileObjectImageFile(document.RootElement, options); + } + + internal static InternalMessageContentItemFileObjectImageFile DeserializeInternalMessageContentItemFileObjectImageFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - return null; + fileId = property.Value.GetString(); + continue; } - string fileId = default; - string detail = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("detail"u8)) { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("detail"u8)) - { - detail = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + detail = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentItemFileObjectImageFile(fileId, detail, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageContentItemFileObjectImageFile(fileId, detail, serializedAdditionalRawData); + } - InternalMessageContentItemFileObjectImageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentItemFileObjectImageFile(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageContentItemFileObjectImageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageContentItemFileObjectImageFile FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentItemFileObjectImageFile(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentItemFileObjectImageFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentItemFileObjectImageFile)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageContentItemFileObjectImageFile FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentItemFileObjectImageFile(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.cs b/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.cs index b002cac9..d622aae7 100644 --- a/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.cs +++ b/src/Generated/Models/InternalMessageContentItemFileObjectImageFile.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentItemFileObjectImageFile { - internal partial class InternalMessageContentItemFileObjectImageFile + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalMessageContentItemFileObjectImageFile(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + internal InternalMessageContentItemFileObjectImageFile(string fileId, string detail, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalMessageContentItemFileObjectImageFile(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } - - internal InternalMessageContentItemFileObjectImageFile(string fileId, string detail, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Detail = detail; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalMessageContentItemFileObjectImageFile() - { - } - - public string FileId { get; set; } + FileId = fileId; + Detail = detail; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalMessageContentItemFileObjectImageFile() + { + } + + public string FileId { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentRefusalObjectType.cs b/src/Generated/Models/InternalMessageContentRefusalObjectType.cs index 7a127f29..2c01fbcc 100644 --- a/src/Generated/Models/InternalMessageContentRefusalObjectType.cs +++ b/src/Generated/Models/InternalMessageContentRefusalObjectType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageContentRefusalObjectType : IEquatable { - internal readonly partial struct InternalMessageContentRefusalObjectType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageContentRefusalObjectType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageContentRefusalObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string RefusalValue = "refusal"; + private const string RefusalValue = "refusal"; - public static InternalMessageContentRefusalObjectType Refusal { get; } = new InternalMessageContentRefusalObjectType(RefusalValue); - public static bool operator ==(InternalMessageContentRefusalObjectType left, InternalMessageContentRefusalObjectType right) => left.Equals(right); - public static bool operator !=(InternalMessageContentRefusalObjectType left, InternalMessageContentRefusalObjectType right) => !left.Equals(right); - public static implicit operator InternalMessageContentRefusalObjectType(string value) => new InternalMessageContentRefusalObjectType(value); + public static InternalMessageContentRefusalObjectType Refusal { get; } = new InternalMessageContentRefusalObjectType(RefusalValue); + public static bool operator ==(InternalMessageContentRefusalObjectType left, InternalMessageContentRefusalObjectType right) => left.Equals(right); + public static bool operator !=(InternalMessageContentRefusalObjectType left, InternalMessageContentRefusalObjectType right) => !left.Equals(right); + public static implicit operator InternalMessageContentRefusalObjectType(string value) => new InternalMessageContentRefusalObjectType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageContentRefusalObjectType other && Equals(other); - public bool Equals(InternalMessageContentRefusalObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageContentRefusalObjectType other && Equals(other); + public bool Equals(InternalMessageContentRefusalObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.Serialization.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.Serialization.cs index a2d9393c..4611e8ab 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.Serialization.cs @@ -8,176 +8,175 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFileCitationObject : IJsonModel { - internal partial class InternalMessageContentTextAnnotationsFileCitationObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("text") != true) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData?.ContainsKey("file_citation") != true) - { - writer.WritePropertyName("file_citation"u8); - writer.WriteObjectValue(FileCitation, options); - } - if (SerializedAdditionalRawData?.ContainsKey("start_index") != true) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex); - } - if (SerializedAdditionalRawData?.ContainsKey("end_index") != true) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("text") != true) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData?.ContainsKey("file_citation") != true) + { + writer.WritePropertyName("file_citation"u8); + writer.WriteObjectValue(FileCitation, options); + } + if (SerializedAdditionalRawData?.ContainsKey("start_index") != true) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex); + } + if (SerializedAdditionalRawData?.ContainsKey("end_index") != true) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageContentTextAnnotationsFileCitationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageContentTextAnnotationsFileCitationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextAnnotationsFileCitationObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support reading '{format}' format."); } - internal static InternalMessageContentTextAnnotationsFileCitationObject DeserializeInternalMessageContentTextAnnotationsFileCitationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentTextAnnotationsFileCitationObject(document.RootElement, options); + } + + internal static InternalMessageContentTextAnnotationsFileCitationObject DeserializeInternalMessageContentTextAnnotationsFileCitationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + InternalMessageContentTextAnnotationsFileCitationObjectFileCitation fileCitation = default; + int startIndex = default; + int endIndex = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) { - return null; + text = property.Value.GetString(); + continue; } - string text = default; - InternalMessageContentTextAnnotationsFileCitationObjectFileCitation fileCitation = default; - int startIndex = default; - int endIndex = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("file_citation"u8)) { - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_citation"u8)) - { - fileCitation = InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileCitation = InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextAnnotationsFileCitationObject( - type, - serializedAdditionalRawData, - text, - fileCitation, - startIndex, - endIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("start_index"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support writing '{options.Format}' format."); + startIndex = property.Value.GetInt32(); + continue; } - } - - InternalMessageContentTextAnnotationsFileCitationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("end_index"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextAnnotationsFileCitationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support reading '{options.Format}' format."); + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageContentTextAnnotationsFileCitationObject( + type, + serializedAdditionalRawData, + text, + fileCitation, + startIndex, + endIndex); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageContentTextAnnotationsFileCitationObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextAnnotationsFileCitationObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalMessageContentTextAnnotationsFileCitationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentTextAnnotationsFileCitationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageContentTextAnnotationsFileCitationObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentTextAnnotationsFileCitationObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.cs index f1a6d8ea..0e49dd91 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObject.cs @@ -5,37 +5,36 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFileCitationObject : InternalMessageContentTextObjectAnnotation { - internal partial class InternalMessageContentTextAnnotationsFileCitationObject : InternalMessageContentTextObjectAnnotation + public InternalMessageContentTextAnnotationsFileCitationObject(string text, InternalMessageContentTextAnnotationsFileCitationObjectFileCitation fileCitation, int startIndex, int endIndex) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(fileCitation, nameof(fileCitation)); + + Type = "file_citation"; + Text = text; + FileCitation = fileCitation; + StartIndex = startIndex; + EndIndex = endIndex; + } + + internal InternalMessageContentTextAnnotationsFileCitationObject(string type, IDictionary serializedAdditionalRawData, string text, InternalMessageContentTextAnnotationsFileCitationObjectFileCitation fileCitation, int startIndex, int endIndex) : base(type, serializedAdditionalRawData) { - public InternalMessageContentTextAnnotationsFileCitationObject(string text, InternalMessageContentTextAnnotationsFileCitationObjectFileCitation fileCitation, int startIndex, int endIndex) - { - Argument.AssertNotNull(text, nameof(text)); - Argument.AssertNotNull(fileCitation, nameof(fileCitation)); - - Type = "file_citation"; - Text = text; - FileCitation = fileCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } - - internal InternalMessageContentTextAnnotationsFileCitationObject(string type, IDictionary serializedAdditionalRawData, string text, InternalMessageContentTextAnnotationsFileCitationObjectFileCitation fileCitation, int startIndex, int endIndex) : base(type, serializedAdditionalRawData) - { - Text = text; - FileCitation = fileCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } - - internal InternalMessageContentTextAnnotationsFileCitationObject() - { - } - - public string Text { get; set; } - public InternalMessageContentTextAnnotationsFileCitationObjectFileCitation FileCitation { get; set; } - public int StartIndex { get; set; } - public int EndIndex { get; set; } + Text = text; + FileCitation = fileCitation; + StartIndex = startIndex; + EndIndex = endIndex; } -} + + internal InternalMessageContentTextAnnotationsFileCitationObject() + { + } + + public string Text { get; set; } + public InternalMessageContentTextAnnotationsFileCitationObjectFileCitation FileCitation { get; set; } + public int StartIndex { get; set; } + public int EndIndex { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs index b1897470..246569f0 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFileCitationObjectFileCitation : IJsonModel { - internal partial class InternalMessageContentTextAnnotationsFileCitationObjectFileCitation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{format}' format."); } - InternalMessageContentTextAnnotationsFileCitationObjectFileCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); } - - internal static InternalMessageContentTextAnnotationsFileCitationObjectFileCitation DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("file_id"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - fileId = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(fileId, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalMessageContentTextAnnotationsFileCitationObjectFileCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{format}' format."); } - InternalMessageContentTextAnnotationsFileCitationObjectFileCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); + } + + internal static InternalMessageContentTextAnnotationsFileCitationObjectFileCitation DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{options.Format}' format."); + fileId = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(fileId, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageContentTextAnnotationsFileCitationObjectFileCitation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{options.Format}' format."); } + } + + InternalMessageContentTextAnnotationsFileCitationObjectFileCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageContentTextAnnotationsFileCitationObjectFileCitation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs index 1c255cb2..dd1632aa 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFileCitationObjectFileCitation.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFileCitationObjectFileCitation { - internal partial class InternalMessageContentTextAnnotationsFileCitationObjectFileCitation + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } + Argument.AssertNotNull(fileId, nameof(fileId)); - internal InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileId = fileId; + } - internal InternalMessageContentTextAnnotationsFileCitationObjectFileCitation() - { - } + internal InternalMessageContentTextAnnotationsFileCitationObjectFileCitation(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string FileId { get; set; } + internal InternalMessageContentTextAnnotationsFileCitationObjectFileCitation() + { } -} + + public string FileId { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.Serialization.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.Serialization.cs index c06a4f2d..5720dd91 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.Serialization.cs @@ -8,176 +8,175 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFilePathObject : IJsonModel { - internal partial class InternalMessageContentTextAnnotationsFilePathObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("text") != true) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData?.ContainsKey("file_path") != true) - { - writer.WritePropertyName("file_path"u8); - writer.WriteObjectValue(FilePath, options); - } - if (SerializedAdditionalRawData?.ContainsKey("start_index") != true) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex); - } - if (SerializedAdditionalRawData?.ContainsKey("end_index") != true) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("text") != true) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData?.ContainsKey("file_path") != true) + { + writer.WritePropertyName("file_path"u8); + writer.WriteObjectValue(FilePath, options); + } + if (SerializedAdditionalRawData?.ContainsKey("start_index") != true) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex); + } + if (SerializedAdditionalRawData?.ContainsKey("end_index") != true) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageContentTextAnnotationsFilePathObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageContentTextAnnotationsFilePathObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextAnnotationsFilePathObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support reading '{format}' format."); } - internal static InternalMessageContentTextAnnotationsFilePathObject DeserializeInternalMessageContentTextAnnotationsFilePathObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentTextAnnotationsFilePathObject(document.RootElement, options); + } + + internal static InternalMessageContentTextAnnotationsFilePathObject DeserializeInternalMessageContentTextAnnotationsFilePathObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + InternalMessageContentTextAnnotationsFilePathObjectFilePath filePath = default; + int startIndex = default; + int endIndex = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) { - return null; + text = property.Value.GetString(); + continue; } - string text = default; - InternalMessageContentTextAnnotationsFilePathObjectFilePath filePath = default; - int startIndex = default; - int endIndex = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("file_path"u8)) { - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_path"u8)) - { - filePath = InternalMessageContentTextAnnotationsFilePathObjectFilePath.DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + filePath = InternalMessageContentTextAnnotationsFilePathObjectFilePath.DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextAnnotationsFilePathObject( - type, - serializedAdditionalRawData, - text, - filePath, - startIndex, - endIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("start_index"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support writing '{options.Format}' format."); + startIndex = property.Value.GetInt32(); + continue; } - } - - InternalMessageContentTextAnnotationsFilePathObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("end_index"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextAnnotationsFilePathObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support reading '{options.Format}' format."); + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageContentTextAnnotationsFilePathObject( + type, + serializedAdditionalRawData, + text, + filePath, + startIndex, + endIndex); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageContentTextAnnotationsFilePathObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextAnnotationsFilePathObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalMessageContentTextAnnotationsFilePathObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentTextAnnotationsFilePathObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageContentTextAnnotationsFilePathObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentTextAnnotationsFilePathObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.cs index c0098007..808e952e 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObject.cs @@ -5,37 +5,36 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFilePathObject : InternalMessageContentTextObjectAnnotation { - internal partial class InternalMessageContentTextAnnotationsFilePathObject : InternalMessageContentTextObjectAnnotation + public InternalMessageContentTextAnnotationsFilePathObject(string text, InternalMessageContentTextAnnotationsFilePathObjectFilePath filePath, int startIndex, int endIndex) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(filePath, nameof(filePath)); + + Type = "file_path"; + Text = text; + FilePath = filePath; + StartIndex = startIndex; + EndIndex = endIndex; + } + + internal InternalMessageContentTextAnnotationsFilePathObject(string type, IDictionary serializedAdditionalRawData, string text, InternalMessageContentTextAnnotationsFilePathObjectFilePath filePath, int startIndex, int endIndex) : base(type, serializedAdditionalRawData) { - public InternalMessageContentTextAnnotationsFilePathObject(string text, InternalMessageContentTextAnnotationsFilePathObjectFilePath filePath, int startIndex, int endIndex) - { - Argument.AssertNotNull(text, nameof(text)); - Argument.AssertNotNull(filePath, nameof(filePath)); - - Type = "file_path"; - Text = text; - FilePath = filePath; - StartIndex = startIndex; - EndIndex = endIndex; - } - - internal InternalMessageContentTextAnnotationsFilePathObject(string type, IDictionary serializedAdditionalRawData, string text, InternalMessageContentTextAnnotationsFilePathObjectFilePath filePath, int startIndex, int endIndex) : base(type, serializedAdditionalRawData) - { - Text = text; - FilePath = filePath; - StartIndex = startIndex; - EndIndex = endIndex; - } - - internal InternalMessageContentTextAnnotationsFilePathObject() - { - } - - public string Text { get; set; } - public InternalMessageContentTextAnnotationsFilePathObjectFilePath FilePath { get; set; } - public int StartIndex { get; set; } - public int EndIndex { get; set; } + Text = text; + FilePath = filePath; + StartIndex = startIndex; + EndIndex = endIndex; } -} + + internal InternalMessageContentTextAnnotationsFilePathObject() + { + } + + public string Text { get; set; } + public InternalMessageContentTextAnnotationsFilePathObjectFilePath FilePath { get; set; } + public int StartIndex { get; set; } + public int EndIndex { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.Serialization.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.Serialization.cs index e398f148..bc3c3ef6 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFilePathObjectFilePath : IJsonModel { - internal partial class InternalMessageContentTextAnnotationsFilePathObjectFilePath : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{format}' format."); } - InternalMessageContentTextAnnotationsFilePathObjectFilePath IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); } - - internal static InternalMessageContentTextAnnotationsFilePathObjectFilePath DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("file_id"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - fileId = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextAnnotationsFilePathObjectFilePath(fileId, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalMessageContentTextAnnotationsFilePathObjectFilePath IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{format}' format."); } - InternalMessageContentTextAnnotationsFilePathObjectFilePath IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); + } + + internal static InternalMessageContentTextAnnotationsFilePathObjectFilePath DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{options.Format}' format."); + fileId = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageContentTextAnnotationsFilePathObjectFilePath(fileId, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageContentTextAnnotationsFilePathObjectFilePath FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{options.Format}' format."); } + } + + InternalMessageContentTextAnnotationsFilePathObjectFilePath IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageContentTextAnnotationsFilePathObjectFilePath FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentTextAnnotationsFilePathObjectFilePath(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.cs b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.cs index de47c05b..334b0548 100644 --- a/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.cs +++ b/src/Generated/Models/InternalMessageContentTextAnnotationsFilePathObjectFilePath.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextAnnotationsFilePathObjectFilePath { - internal partial class InternalMessageContentTextAnnotationsFilePathObjectFilePath + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalMessageContentTextAnnotationsFilePathObjectFilePath(string fileId) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalMessageContentTextAnnotationsFilePathObjectFilePath(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } + Argument.AssertNotNull(fileId, nameof(fileId)); - internal InternalMessageContentTextAnnotationsFilePathObjectFilePath(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileId = fileId; + } - internal InternalMessageContentTextAnnotationsFilePathObjectFilePath() - { - } + internal InternalMessageContentTextAnnotationsFilePathObjectFilePath(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string FileId { get; set; } + internal InternalMessageContentTextAnnotationsFilePathObjectFilePath() + { } -} + + public string FileId { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextObjectAnnotation.Serialization.cs b/src/Generated/Models/InternalMessageContentTextObjectAnnotation.Serialization.cs index 92f8d5b7..221faf6e 100644 --- a/src/Generated/Models/InternalMessageContentTextObjectAnnotation.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentTextObjectAnnotation.Serialization.cs @@ -7,118 +7,117 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownMessageContentTextObjectAnnotation))] +internal partial class InternalMessageContentTextObjectAnnotation : IJsonModel { - [PersistableModelProxy(typeof(UnknownMessageContentTextObjectAnnotation))] - internal partial class InternalMessageContentTextObjectAnnotation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageContentTextObjectAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageContentTextObjectAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{format}' format."); } - internal static InternalMessageContentTextObjectAnnotation DeserializeInternalMessageContentTextObjectAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "file_citation": return InternalMessageContentTextAnnotationsFileCitationObject.DeserializeInternalMessageContentTextAnnotationsFileCitationObject(element, options); - case "file_path": return InternalMessageContentTextAnnotationsFilePathObject.DeserializeInternalMessageContentTextAnnotationsFilePathObject(element, options); - } - } - return UnknownMessageContentTextObjectAnnotation.DeserializeUnknownMessageContentTextObjectAnnotation(element, options); - } + internal static InternalMessageContentTextObjectAnnotation DeserializeInternalMessageContentTextObjectAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalMessageContentTextObjectAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{options.Format}' format."); + case "file_citation": return InternalMessageContentTextAnnotationsFileCitationObject.DeserializeInternalMessageContentTextAnnotationsFileCitationObject(element, options); + case "file_path": return InternalMessageContentTextAnnotationsFilePathObject.DeserializeInternalMessageContentTextAnnotationsFilePathObject(element, options); } } + return UnknownMessageContentTextObjectAnnotation.DeserializeUnknownMessageContentTextObjectAnnotation(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageContentTextObjectAnnotation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalMessageContentTextObjectAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageContentTextObjectAnnotation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextObjectAnnotation.cs b/src/Generated/Models/InternalMessageContentTextObjectAnnotation.cs index 4e2df613..6dffcb9f 100644 --- a/src/Generated/Models/InternalMessageContentTextObjectAnnotation.cs +++ b/src/Generated/Models/InternalMessageContentTextObjectAnnotation.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal abstract partial class InternalMessageContentTextObjectAnnotation { - internal abstract partial class InternalMessageContentTextObjectAnnotation + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalMessageContentTextObjectAnnotation() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalMessageContentTextObjectAnnotation() - { - } - - internal InternalMessageContentTextObjectAnnotation(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalMessageContentTextObjectAnnotation(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextObjectText.Serialization.cs b/src/Generated/Models/InternalMessageContentTextObjectText.Serialization.cs index 0c951aee..7de941fa 100644 --- a/src/Generated/Models/InternalMessageContentTextObjectText.Serialization.cs +++ b/src/Generated/Models/InternalMessageContentTextObjectText.Serialization.cs @@ -8,147 +8,146 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextObjectText : IJsonModel { - internal partial class InternalMessageContentTextObjectText : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("value") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("value") != true) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (SerializedAdditionalRawData?.ContainsKey("annotations") != true) + { + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (var item in Annotations) { - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("annotations") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("annotations"u8); - writer.WriteStartArray(); - foreach (var item in Annotations) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageContentTextObjectText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageContentTextObjectText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextObjectText(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support reading '{format}' format."); } - internal static InternalMessageContentTextObjectText DeserializeInternalMessageContentTextObjectText(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentTextObjectText(document.RootElement, options); + } + + internal static InternalMessageContentTextObjectText DeserializeInternalMessageContentTextObjectText(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + IList annotations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) { - return null; + value = property.Value.GetString(); + continue; } - string value = default; - IList annotations = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("annotations"u8)) { - if (property.NameEquals("value"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - value = property.Value.GetString(); - continue; - } - if (property.NameEquals("annotations"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalMessageContentTextObjectAnnotation.DeserializeInternalMessageContentTextObjectAnnotation(item, options)); - } - annotations = array; - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalMessageContentTextObjectAnnotation.DeserializeInternalMessageContentTextObjectAnnotation(item, options)); } + annotations = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextObjectText(value, annotations, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageContentTextObjectText(value, annotations, serializedAdditionalRawData); + } - InternalMessageContentTextObjectText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextObjectText(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageContentTextObjectText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageContentTextObjectText FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextObjectText(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentTextObjectText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectText)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageContentTextObjectText FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageContentTextObjectText(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextObjectText.cs b/src/Generated/Models/InternalMessageContentTextObjectText.cs index 3ebc901f..cfdbe6e9 100644 --- a/src/Generated/Models/InternalMessageContentTextObjectText.cs +++ b/src/Generated/Models/InternalMessageContentTextObjectText.cs @@ -6,32 +6,31 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageContentTextObjectText { - internal partial class InternalMessageContentTextObjectText + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalMessageContentTextObjectText(string value, IEnumerable annotations) + { + Argument.AssertNotNull(value, nameof(value)); + Argument.AssertNotNull(annotations, nameof(annotations)); + + Value = value; + Annotations = annotations.ToList(); + } + + internal InternalMessageContentTextObjectText(string value, IList annotations, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalMessageContentTextObjectText(string value, IEnumerable annotations) - { - Argument.AssertNotNull(value, nameof(value)); - Argument.AssertNotNull(annotations, nameof(annotations)); - - Value = value; - Annotations = annotations.ToList(); - } - - internal InternalMessageContentTextObjectText(string value, IList annotations, IDictionary serializedAdditionalRawData) - { - Value = value; - Annotations = annotations; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalMessageContentTextObjectText() - { - } - - public string Value { get; set; } - public IList Annotations { get; } + Value = value; + Annotations = annotations; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalMessageContentTextObjectText() + { + } + + public string Value { get; set; } + public IList Annotations { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageContentTextObjectType.cs b/src/Generated/Models/InternalMessageContentTextObjectType.cs index daf657e1..f580dcab 100644 --- a/src/Generated/Models/InternalMessageContentTextObjectType.cs +++ b/src/Generated/Models/InternalMessageContentTextObjectType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageContentTextObjectType : IEquatable { - internal readonly partial struct InternalMessageContentTextObjectType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageContentTextObjectType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageContentTextObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TextValue = "text"; + private const string TextValue = "text"; - public static InternalMessageContentTextObjectType Text { get; } = new InternalMessageContentTextObjectType(TextValue); - public static bool operator ==(InternalMessageContentTextObjectType left, InternalMessageContentTextObjectType right) => left.Equals(right); - public static bool operator !=(InternalMessageContentTextObjectType left, InternalMessageContentTextObjectType right) => !left.Equals(right); - public static implicit operator InternalMessageContentTextObjectType(string value) => new InternalMessageContentTextObjectType(value); + public static InternalMessageContentTextObjectType Text { get; } = new InternalMessageContentTextObjectType(TextValue); + public static bool operator ==(InternalMessageContentTextObjectType left, InternalMessageContentTextObjectType right) => left.Equals(right); + public static bool operator !=(InternalMessageContentTextObjectType left, InternalMessageContentTextObjectType right) => !left.Equals(right); + public static implicit operator InternalMessageContentTextObjectType(string value) => new InternalMessageContentTextObjectType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageContentTextObjectType other && Equals(other); - public bool Equals(InternalMessageContentTextObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageContentTextObjectType other && Equals(other); + public bool Equals(InternalMessageContentTextObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContent.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContent.Serialization.cs index 7b0d037e..0600ccfe 100644 --- a/src/Generated/Models/InternalMessageDeltaContent.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContent.Serialization.cs @@ -7,120 +7,119 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownMessageDeltaContent))] +internal partial class InternalMessageDeltaContent : IJsonModel { - [PersistableModelProxy(typeof(UnknownMessageDeltaContent))] - internal partial class InternalMessageDeltaContent : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContent(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContent DeserializeInternalMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContent(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "image_file": return InternalMessageDeltaContentImageFileObject.DeserializeInternalMessageDeltaContentImageFileObject(element, options); - case "image_url": return InternalMessageDeltaContentImageUrlObject.DeserializeInternalMessageDeltaContentImageUrlObject(element, options); - case "refusal": return InternalMessageDeltaContentRefusalObject.DeserializeInternalMessageDeltaContentRefusalObject(element, options); - case "text": return InternalMessageDeltaContentTextObject.DeserializeInternalMessageDeltaContentTextObject(element, options); - } - } - return UnknownMessageDeltaContent.DeserializeUnknownMessageDeltaContent(element, options); - } + internal static InternalMessageDeltaContent DeserializeInternalMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalMessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{options.Format}' format."); + case "image_file": return InternalMessageDeltaContentImageFileObject.DeserializeInternalMessageDeltaContentImageFileObject(element, options); + case "image_url": return InternalMessageDeltaContentImageUrlObject.DeserializeInternalMessageDeltaContentImageUrlObject(element, options); + case "refusal": return InternalMessageDeltaContentRefusalObject.DeserializeInternalMessageDeltaContentRefusalObject(element, options); + case "text": return InternalMessageDeltaContentTextObject.DeserializeInternalMessageDeltaContentTextObject(element, options); } } + return UnknownMessageDeltaContent.DeserializeUnknownMessageDeltaContent(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContent(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalMessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContent(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContent.cs b/src/Generated/Models/InternalMessageDeltaContent.cs index 861574e9..6f6e3837 100644 --- a/src/Generated/Models/InternalMessageDeltaContent.cs +++ b/src/Generated/Models/InternalMessageDeltaContent.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal abstract partial class InternalMessageDeltaContent { - internal abstract partial class InternalMessageDeltaContent + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalMessageDeltaContent() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalMessageDeltaContent() - { - } - - internal InternalMessageDeltaContent(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalMessageDeltaContent(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageFileObject.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentImageFileObject.Serialization.cs index 56a49b62..0b6effed 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageFileObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageFileObject.Serialization.cs @@ -8,152 +8,151 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageFileObject : IJsonModel { - internal partial class InternalMessageDeltaContentImageFileObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("image_file") != true && Optional.IsDefined(ImageFile)) - { - writer.WritePropertyName("image_file"u8); - writer.WriteObjectValue(ImageFile, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("image_file") != true && Optional.IsDefined(ImageFile)) + { + writer.WritePropertyName("image_file"u8); + writer.WriteObjectValue(ImageFile, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentImageFileObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentImageFileObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentImageFileObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentImageFileObject DeserializeInternalMessageDeltaContentImageFileObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentImageFileObject(document.RootElement, options); + } + + internal static InternalMessageDeltaContentImageFileObject DeserializeInternalMessageDeltaContentImageFileObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + InternalMessageDeltaContentImageFileObjectImageFile imageFile = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - InternalMessageDeltaContentImageFileObjectImageFile imageFile = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("image_file"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("image_file"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - imageFile = InternalMessageDeltaContentImageFileObjectImageFile.DeserializeInternalMessageDeltaContentImageFileObjectImageFile(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + imageFile = InternalMessageDeltaContentImageFileObjectImageFile.DeserializeInternalMessageDeltaContentImageFileObjectImageFile(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentImageFileObject(type, serializedAdditionalRawData, index, imageFile); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalMessageDeltaContentImageFileObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentImageFileObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentImageFileObject(type, serializedAdditionalRawData, index, imageFile); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageDeltaContentImageFileObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentImageFileObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaContentImageFileObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentImageFileObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageDeltaContentImageFileObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentImageFileObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageFileObject.cs b/src/Generated/Models/InternalMessageDeltaContentImageFileObject.cs index 09615bda..35be3b7d 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageFileObject.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageFileObject.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageFileObject : InternalMessageDeltaContent { - internal partial class InternalMessageDeltaContentImageFileObject : InternalMessageDeltaContent + internal InternalMessageDeltaContentImageFileObject(int index) { - internal InternalMessageDeltaContentImageFileObject(int index) - { - Type = "image_file"; - Index = index; - } - - internal InternalMessageDeltaContentImageFileObject(string type, IDictionary serializedAdditionalRawData, int index, InternalMessageDeltaContentImageFileObjectImageFile imageFile) : base(type, serializedAdditionalRawData) - { - Index = index; - ImageFile = imageFile; - } + Type = "image_file"; + Index = index; + } - internal InternalMessageDeltaContentImageFileObject() - { - } + internal InternalMessageDeltaContentImageFileObject(string type, IDictionary serializedAdditionalRawData, int index, InternalMessageDeltaContentImageFileObjectImageFile imageFile) : base(type, serializedAdditionalRawData) + { + Index = index; + ImageFile = imageFile; + } - public int Index { get; } - public InternalMessageDeltaContentImageFileObjectImageFile ImageFile { get; } + internal InternalMessageDeltaContentImageFileObject() + { } -} + + public int Index { get; } + public InternalMessageDeltaContentImageFileObjectImageFile ImageFile { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.Serialization.cs index aeba95b5..888edb34 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageFileObjectImageFile : IJsonModel { - internal partial class InternalMessageDeltaContentImageFileObjectImageFile : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) - { - writer.WritePropertyName("detail"u8); - writer.WriteStringValue(Detail); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentImageFileObjectImageFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentImageFileObjectImageFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentImageFileObjectImageFile(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentImageFileObjectImageFile DeserializeInternalMessageDeltaContentImageFileObjectImageFile(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentImageFileObjectImageFile(document.RootElement, options); + } + + internal static InternalMessageDeltaContentImageFileObjectImageFile DeserializeInternalMessageDeltaContentImageFileObjectImageFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - return null; + fileId = property.Value.GetString(); + continue; } - string fileId = default; - string detail = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("detail"u8)) { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("detail"u8)) - { - detail = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + detail = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentImageFileObjectImageFile(fileId, detail, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentImageFileObjectImageFile(fileId, detail, serializedAdditionalRawData); + } - InternalMessageDeltaContentImageFileObjectImageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentImageFileObjectImageFile(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageDeltaContentImageFileObjectImageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaContentImageFileObjectImageFile FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentImageFileObjectImageFile(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentImageFileObjectImageFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageFileObjectImageFile)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaContentImageFileObjectImageFile FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentImageFileObjectImageFile(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.cs b/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.cs index ce44aab8..0c193e0c 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFile.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageFileObjectImageFile { - internal partial class InternalMessageDeltaContentImageFileObjectImageFile + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageDeltaContentImageFileObjectImageFile() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageDeltaContentImageFileObjectImageFile() - { - } - - internal InternalMessageDeltaContentImageFileObjectImageFile(string fileId, string detail, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Detail = detail; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string FileId { get; } + internal InternalMessageDeltaContentImageFileObjectImageFile(string fileId, string detail, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Detail = detail; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string FileId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFileDetail.cs b/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFileDetail.cs index 3de4b3ed..33c67c15 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFileDetail.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageFileObjectImageFileDetail.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageDeltaContentImageFileObjectImageFileDetail : IEquatable { - internal readonly partial struct InternalMessageDeltaContentImageFileObjectImageFileDetail : IEquatable + private readonly string _value; + + public InternalMessageDeltaContentImageFileObjectImageFileDetail(string value) { - private readonly string _value; - - public InternalMessageDeltaContentImageFileObjectImageFileDetail(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string LowValue = "low"; - private const string HighValue = "high"; - - public static InternalMessageDeltaContentImageFileObjectImageFileDetail Auto { get; } = new InternalMessageDeltaContentImageFileObjectImageFileDetail(AutoValue); - public static InternalMessageDeltaContentImageFileObjectImageFileDetail Low { get; } = new InternalMessageDeltaContentImageFileObjectImageFileDetail(LowValue); - public static InternalMessageDeltaContentImageFileObjectImageFileDetail High { get; } = new InternalMessageDeltaContentImageFileObjectImageFileDetail(HighValue); - public static bool operator ==(InternalMessageDeltaContentImageFileObjectImageFileDetail left, InternalMessageDeltaContentImageFileObjectImageFileDetail right) => left.Equals(right); - public static bool operator !=(InternalMessageDeltaContentImageFileObjectImageFileDetail left, InternalMessageDeltaContentImageFileObjectImageFileDetail right) => !left.Equals(right); - public static implicit operator InternalMessageDeltaContentImageFileObjectImageFileDetail(string value) => new InternalMessageDeltaContentImageFileObjectImageFileDetail(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageDeltaContentImageFileObjectImageFileDetail other && Equals(other); - public bool Equals(InternalMessageDeltaContentImageFileObjectImageFileDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AutoValue = "auto"; + private const string LowValue = "low"; + private const string HighValue = "high"; + + public static InternalMessageDeltaContentImageFileObjectImageFileDetail Auto { get; } = new InternalMessageDeltaContentImageFileObjectImageFileDetail(AutoValue); + public static InternalMessageDeltaContentImageFileObjectImageFileDetail Low { get; } = new InternalMessageDeltaContentImageFileObjectImageFileDetail(LowValue); + public static InternalMessageDeltaContentImageFileObjectImageFileDetail High { get; } = new InternalMessageDeltaContentImageFileObjectImageFileDetail(HighValue); + public static bool operator ==(InternalMessageDeltaContentImageFileObjectImageFileDetail left, InternalMessageDeltaContentImageFileObjectImageFileDetail right) => left.Equals(right); + public static bool operator !=(InternalMessageDeltaContentImageFileObjectImageFileDetail left, InternalMessageDeltaContentImageFileObjectImageFileDetail right) => !left.Equals(right); + public static implicit operator InternalMessageDeltaContentImageFileObjectImageFileDetail(string value) => new InternalMessageDeltaContentImageFileObjectImageFileDetail(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageDeltaContentImageFileObjectImageFileDetail other && Equals(other); + public bool Equals(InternalMessageDeltaContentImageFileObjectImageFileDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.Serialization.cs index 40317ea4..d5e48cd1 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.Serialization.cs @@ -8,152 +8,151 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageUrlObject : IJsonModel { - internal partial class InternalMessageDeltaContentImageUrlObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("image_url") != true && Optional.IsDefined(ImageUrl)) - { - writer.WritePropertyName("image_url"u8); - writer.WriteObjectValue(ImageUrl, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("image_url") != true && Optional.IsDefined(ImageUrl)) + { + writer.WritePropertyName("image_url"u8); + writer.WriteObjectValue(ImageUrl, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentImageUrlObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentImageUrlObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentImageUrlObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentImageUrlObject DeserializeInternalMessageDeltaContentImageUrlObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentImageUrlObject(document.RootElement, options); + } + + internal static InternalMessageDeltaContentImageUrlObject DeserializeInternalMessageDeltaContentImageUrlObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + InternalMessageDeltaContentImageUrlObjectImageUrl imageUrl = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - InternalMessageDeltaContentImageUrlObjectImageUrl imageUrl = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("image_url"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("image_url"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - imageUrl = InternalMessageDeltaContentImageUrlObjectImageUrl.DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + imageUrl = InternalMessageDeltaContentImageUrlObjectImageUrl.DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentImageUrlObject(type, serializedAdditionalRawData, index, imageUrl); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalMessageDeltaContentImageUrlObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentImageUrlObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentImageUrlObject(type, serializedAdditionalRawData, index, imageUrl); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageDeltaContentImageUrlObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentImageUrlObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaContentImageUrlObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentImageUrlObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageDeltaContentImageUrlObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentImageUrlObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.cs b/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.cs index 07fa17e8..85fbd423 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageUrlObject.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageUrlObject : InternalMessageDeltaContent { - internal partial class InternalMessageDeltaContentImageUrlObject : InternalMessageDeltaContent + internal InternalMessageDeltaContentImageUrlObject(int index) { - internal InternalMessageDeltaContentImageUrlObject(int index) - { - Type = "image_url"; - Index = index; - } - - internal InternalMessageDeltaContentImageUrlObject(string type, IDictionary serializedAdditionalRawData, int index, InternalMessageDeltaContentImageUrlObjectImageUrl imageUrl) : base(type, serializedAdditionalRawData) - { - Index = index; - ImageUrl = imageUrl; - } + Type = "image_url"; + Index = index; + } - internal InternalMessageDeltaContentImageUrlObject() - { - } + internal InternalMessageDeltaContentImageUrlObject(string type, IDictionary serializedAdditionalRawData, int index, InternalMessageDeltaContentImageUrlObjectImageUrl imageUrl) : base(type, serializedAdditionalRawData) + { + Index = index; + ImageUrl = imageUrl; + } - public int Index { get; } - public InternalMessageDeltaContentImageUrlObjectImageUrl ImageUrl { get; } + internal InternalMessageDeltaContentImageUrlObject() + { } -} + + public int Index { get; } + public InternalMessageDeltaContentImageUrlObjectImageUrl ImageUrl { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.Serialization.cs index 17fdc9aa..885ada7e 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.Serialization.cs @@ -8,141 +8,140 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageUrlObjectImageUrl : IJsonModel { - internal partial class InternalMessageDeltaContentImageUrlObjectImageUrl : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(Url)) - { - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url.AbsoluteUri); - } - if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) - { - writer.WritePropertyName("detail"u8); - writer.WriteStringValue(Detail); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(Url)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + if (SerializedAdditionalRawData?.ContainsKey("detail") != true && Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentImageUrlObjectImageUrl IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentImageUrlObjectImageUrl IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentImageUrlObjectImageUrl DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - Uri url = default; - string detail = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalMessageDeltaContentImageUrlObjectImageUrl DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri url = default; + string detail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) { - if (property.NameEquals("url"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - url = new Uri(property.Value.GetString()); - continue; - } - if (property.NameEquals("detail"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - detail = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + url = new Uri(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentImageUrlObjectImageUrl(url, detail, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("detail"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support writing '{options.Format}' format."); + detail = property.Value.GetString(); + continue; } - } - - InternalMessageDeltaContentImageUrlObjectImageUrl IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentImageUrlObjectImageUrl(url, detail, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaContentImageUrlObjectImageUrl FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalMessageDeltaContentImageUrlObjectImageUrl IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentImageUrlObjectImageUrl)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaContentImageUrlObjectImageUrl FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentImageUrlObjectImageUrl(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.cs b/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.cs index 886c7899..753df3b6 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrl.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentImageUrlObjectImageUrl { - internal partial class InternalMessageDeltaContentImageUrlObjectImageUrl + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageDeltaContentImageUrlObjectImageUrl() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageDeltaContentImageUrlObjectImageUrl() - { - } - - internal InternalMessageDeltaContentImageUrlObjectImageUrl(Uri url, string detail, IDictionary serializedAdditionalRawData) - { - Url = url; - Detail = detail; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public Uri Url { get; } + internal InternalMessageDeltaContentImageUrlObjectImageUrl(Uri url, string detail, IDictionary serializedAdditionalRawData) + { + Url = url; + Detail = detail; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public Uri Url { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrlDetail.cs b/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrlDetail.cs index ffd7b7bb..72819101 100644 --- a/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrlDetail.cs +++ b/src/Generated/Models/InternalMessageDeltaContentImageUrlObjectImageUrlDetail.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageDeltaContentImageUrlObjectImageUrlDetail : IEquatable { - internal readonly partial struct InternalMessageDeltaContentImageUrlObjectImageUrlDetail : IEquatable + private readonly string _value; + + public InternalMessageDeltaContentImageUrlObjectImageUrlDetail(string value) { - private readonly string _value; - - public InternalMessageDeltaContentImageUrlObjectImageUrlDetail(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AutoValue = "auto"; - private const string LowValue = "low"; - private const string HighValue = "high"; - - public static InternalMessageDeltaContentImageUrlObjectImageUrlDetail Auto { get; } = new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(AutoValue); - public static InternalMessageDeltaContentImageUrlObjectImageUrlDetail Low { get; } = new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(LowValue); - public static InternalMessageDeltaContentImageUrlObjectImageUrlDetail High { get; } = new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(HighValue); - public static bool operator ==(InternalMessageDeltaContentImageUrlObjectImageUrlDetail left, InternalMessageDeltaContentImageUrlObjectImageUrlDetail right) => left.Equals(right); - public static bool operator !=(InternalMessageDeltaContentImageUrlObjectImageUrlDetail left, InternalMessageDeltaContentImageUrlObjectImageUrlDetail right) => !left.Equals(right); - public static implicit operator InternalMessageDeltaContentImageUrlObjectImageUrlDetail(string value) => new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageDeltaContentImageUrlObjectImageUrlDetail other && Equals(other); - public bool Equals(InternalMessageDeltaContentImageUrlObjectImageUrlDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AutoValue = "auto"; + private const string LowValue = "low"; + private const string HighValue = "high"; + + public static InternalMessageDeltaContentImageUrlObjectImageUrlDetail Auto { get; } = new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(AutoValue); + public static InternalMessageDeltaContentImageUrlObjectImageUrlDetail Low { get; } = new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(LowValue); + public static InternalMessageDeltaContentImageUrlObjectImageUrlDetail High { get; } = new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(HighValue); + public static bool operator ==(InternalMessageDeltaContentImageUrlObjectImageUrlDetail left, InternalMessageDeltaContentImageUrlObjectImageUrlDetail right) => left.Equals(right); + public static bool operator !=(InternalMessageDeltaContentImageUrlObjectImageUrlDetail left, InternalMessageDeltaContentImageUrlObjectImageUrlDetail right) => !left.Equals(right); + public static implicit operator InternalMessageDeltaContentImageUrlObjectImageUrlDetail(string value) => new InternalMessageDeltaContentImageUrlObjectImageUrlDetail(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageDeltaContentImageUrlObjectImageUrlDetail other && Equals(other); + public bool Equals(InternalMessageDeltaContentImageUrlObjectImageUrlDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentRefusalObject.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentRefusalObject.Serialization.cs index 1668fc35..614e56bf 100644 --- a/src/Generated/Models/InternalMessageDeltaContentRefusalObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentRefusalObject.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentRefusalObject : IJsonModel { - internal partial class InternalMessageDeltaContentRefusalObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("refusal") != true && Optional.IsDefined(Refusal)) - { - writer.WritePropertyName("refusal"u8); - writer.WriteStringValue(Refusal); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("refusal") != true && Optional.IsDefined(Refusal)) + { + writer.WritePropertyName("refusal"u8); + writer.WriteStringValue(Refusal); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentRefusalObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentRefusalObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentRefusalObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentRefusalObject DeserializeInternalMessageDeltaContentRefusalObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentRefusalObject(document.RootElement, options); + } + + internal static InternalMessageDeltaContentRefusalObject DeserializeInternalMessageDeltaContentRefusalObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string refusal = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string refusal = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("refusal"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("refusal"u8)) - { - refusal = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + refusal = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentRefusalObject(type, serializedAdditionalRawData, index, refusal); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalMessageDeltaContentRefusalObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentRefusalObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentRefusalObject(type, serializedAdditionalRawData, index, refusal); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageDeltaContentRefusalObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentRefusalObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaContentRefusalObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentRefusalObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentRefusalObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageDeltaContentRefusalObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentRefusalObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentRefusalObject.cs b/src/Generated/Models/InternalMessageDeltaContentRefusalObject.cs index d7b88a83..3962cae5 100644 --- a/src/Generated/Models/InternalMessageDeltaContentRefusalObject.cs +++ b/src/Generated/Models/InternalMessageDeltaContentRefusalObject.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentRefusalObject : InternalMessageDeltaContent { - internal partial class InternalMessageDeltaContentRefusalObject : InternalMessageDeltaContent + internal InternalMessageDeltaContentRefusalObject(int index) { - internal InternalMessageDeltaContentRefusalObject(int index) - { - Type = "refusal"; - Index = index; - } - - internal InternalMessageDeltaContentRefusalObject(string type, IDictionary serializedAdditionalRawData, int index, string refusal) : base(type, serializedAdditionalRawData) - { - Index = index; - Refusal = refusal; - } + Type = "refusal"; + Index = index; + } - internal InternalMessageDeltaContentRefusalObject() - { - } + internal InternalMessageDeltaContentRefusalObject(string type, IDictionary serializedAdditionalRawData, int index, string refusal) : base(type, serializedAdditionalRawData) + { + Index = index; + Refusal = refusal; + } - public int Index { get; } - public string Refusal { get; } + internal InternalMessageDeltaContentRefusalObject() + { } -} + + public int Index { get; } + public string Refusal { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.Serialization.cs index f35ad097..4fa0e03a 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.Serialization.cs @@ -8,200 +8,199 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObject : IJsonModel { - internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData?.ContainsKey("file_citation") != true && Optional.IsDefined(FileCitation)) - { - writer.WritePropertyName("file_citation"u8); - writer.WriteObjectValue(FileCitation, options); - } - if (SerializedAdditionalRawData?.ContainsKey("start_index") != true && Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("end_index") != true && Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData?.ContainsKey("file_citation") != true && Optional.IsDefined(FileCitation)) + { + writer.WritePropertyName("file_citation"u8); + writer.WriteObjectValue(FileCitation, options); + } + if (SerializedAdditionalRawData?.ContainsKey("start_index") != true && Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("end_index") != true && Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentTextAnnotationsFileCitationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentTextAnnotationsFileCitationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentTextAnnotationsFileCitationObject DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(document.RootElement, options); + } + + internal static InternalMessageDeltaContentTextAnnotationsFileCitationObject DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string text = default; + InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation fileCitation = default; + int? startIndex = default; + int? endIndex = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string text = default; - InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation fileCitation = default; - int? startIndex = default; - int? endIndex = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("text"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_citation"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileCitation = InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("file_citation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("end_index"u8)) + fileCitation = InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("type"u8)) + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + endIndex = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextAnnotationsFileCitationObject( - type, - serializedAdditionalRawData, - index, - text, - fileCitation, - startIndex, - endIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalMessageDeltaContentTextAnnotationsFileCitationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentTextAnnotationsFileCitationObject( + type, + serializedAdditionalRawData, + index, + text, + fileCitation, + startIndex, + endIndex); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageDeltaContentTextAnnotationsFileCitationObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalMessageDeltaContentTextAnnotationsFileCitationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageDeltaContentTextAnnotationsFileCitationObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.cs index a96c6651..1173437f 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObject.cs @@ -5,33 +5,32 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObject : InternalMessageDeltaTextContentAnnotation { - internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObject : InternalMessageDeltaTextContentAnnotation + internal InternalMessageDeltaContentTextAnnotationsFileCitationObject(int index) { - internal InternalMessageDeltaContentTextAnnotationsFileCitationObject(int index) - { - Type = "file_citation"; - Index = index; - } - - internal InternalMessageDeltaContentTextAnnotationsFileCitationObject(string type, IDictionary serializedAdditionalRawData, int index, string text, InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation fileCitation, int? startIndex, int? endIndex) : base(type, serializedAdditionalRawData) - { - Index = index; - Text = text; - FileCitation = fileCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } + Type = "file_citation"; + Index = index; + } - internal InternalMessageDeltaContentTextAnnotationsFileCitationObject() - { - } + internal InternalMessageDeltaContentTextAnnotationsFileCitationObject(string type, IDictionary serializedAdditionalRawData, int index, string text, InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation fileCitation, int? startIndex, int? endIndex) : base(type, serializedAdditionalRawData) + { + Index = index; + Text = text; + FileCitation = fileCitation; + StartIndex = startIndex; + EndIndex = endIndex; + } - public int Index { get; } - public string Text { get; } - public InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation FileCitation { get; } - public int? StartIndex { get; } - public int? EndIndex { get; } + internal InternalMessageDeltaContentTextAnnotationsFileCitationObject() + { } -} + + public int Index { get; } + public string Text { get; } + public InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation FileCitation { get; } + public int? StartIndex { get; } + public int? EndIndex { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs index 61580bfd..e636cb15 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation : IJsonModel { - internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("quote") != true && Optional.IsDefined(Quote)) - { - writer.WritePropertyName("quote"u8); - writer.WriteStringValue(Quote); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("quote") != true && Optional.IsDefined(Quote)) + { + writer.WritePropertyName("quote"u8); + writer.WriteStringValue(Quote); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); + } + + internal static InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string quote = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - return null; + fileId = property.Value.GetString(); + continue; } - string fileId = default; - string quote = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("quote"u8)) { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("quote"u8)) - { - quote = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + quote = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(fileId, quote, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(fileId, quote, serializedAdditionalRawData); + } - InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.cs index 8451e215..741f31b2 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation { - internal partial class InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation() - { - } - - internal InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(string fileId, string quote, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Quote = quote; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string FileId { get; } - public string Quote { get; } + internal InternalMessageDeltaContentTextAnnotationsFileCitationObjectFileCitation(string fileId, string quote, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Quote = quote; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string FileId { get; } + public string Quote { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.Serialization.cs index 1ed21a80..fb893d4d 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.Serialization.cs @@ -8,200 +8,199 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObject : IJsonModel { - internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData?.ContainsKey("file_path") != true && Optional.IsDefined(FilePath)) - { - writer.WritePropertyName("file_path"u8); - writer.WriteObjectValue(FilePath, options); - } - if (SerializedAdditionalRawData?.ContainsKey("start_index") != true && Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("end_index") != true && Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData?.ContainsKey("file_path") != true && Optional.IsDefined(FilePath)) + { + writer.WritePropertyName("file_path"u8); + writer.WriteObjectValue(FilePath, options); + } + if (SerializedAdditionalRawData?.ContainsKey("start_index") != true && Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("end_index") != true && Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentTextAnnotationsFilePathObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentTextAnnotationsFilePathObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentTextAnnotationsFilePathObject DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(document.RootElement, options); + } + + internal static InternalMessageDeltaContentTextAnnotationsFilePathObject DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string text = default; + InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath filePath = default; + int? startIndex = default; + int? endIndex = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string text = default; - InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath filePath = default; - int? startIndex = default; - int? endIndex = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("text"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_path"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - filePath = InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("file_path"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("end_index"u8)) + filePath = InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("type"u8)) + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + endIndex = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextAnnotationsFilePathObject( - type, - serializedAdditionalRawData, - index, - text, - filePath, - startIndex, - endIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalMessageDeltaContentTextAnnotationsFilePathObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentTextAnnotationsFilePathObject( + type, + serializedAdditionalRawData, + index, + text, + filePath, + startIndex, + endIndex); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageDeltaContentTextAnnotationsFilePathObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalMessageDeltaContentTextAnnotationsFilePathObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageDeltaContentTextAnnotationsFilePathObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.cs index 92320c4f..1eed07f2 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObject.cs @@ -5,33 +5,32 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObject : InternalMessageDeltaTextContentAnnotation { - internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObject : InternalMessageDeltaTextContentAnnotation + internal InternalMessageDeltaContentTextAnnotationsFilePathObject(int index) { - internal InternalMessageDeltaContentTextAnnotationsFilePathObject(int index) - { - Type = "file_path"; - Index = index; - } - - internal InternalMessageDeltaContentTextAnnotationsFilePathObject(string type, IDictionary serializedAdditionalRawData, int index, string text, InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath filePath, int? startIndex, int? endIndex) : base(type, serializedAdditionalRawData) - { - Index = index; - Text = text; - FilePath = filePath; - StartIndex = startIndex; - EndIndex = endIndex; - } + Type = "file_path"; + Index = index; + } - internal InternalMessageDeltaContentTextAnnotationsFilePathObject() - { - } + internal InternalMessageDeltaContentTextAnnotationsFilePathObject(string type, IDictionary serializedAdditionalRawData, int index, string text, InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath filePath, int? startIndex, int? endIndex) : base(type, serializedAdditionalRawData) + { + Index = index; + Text = text; + FilePath = filePath; + StartIndex = startIndex; + EndIndex = endIndex; + } - public int Index { get; } - public string Text { get; } - public InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath FilePath { get; } - public int? StartIndex { get; } - public int? EndIndex { get; } + internal InternalMessageDeltaContentTextAnnotationsFilePathObject() + { } -} + + public int Index { get; } + public string Text { get; } + public InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath FilePath { get; } + public int? StartIndex { get; } + public int? EndIndex { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.Serialization.cs index 2cabf159..7dc0966a 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath : IJsonModel { - internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{format}' format."); } - InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); } - - internal static InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("file_id"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - fileId = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(fileId, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{format}' format."); } - InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); + } + + internal static InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{options.Format}' format."); + fileId = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(fileId, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.cs b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.cs index 3e41f99b..48ae50ee 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath { - internal partial class InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath() - { - } - - internal InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string FileId { get; } + internal InternalMessageDeltaContentTextAnnotationsFilePathObjectFilePath(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string FileId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextObject.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentTextObject.Serialization.cs index 75983efa..f6549e71 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextObject.Serialization.cs @@ -8,152 +8,151 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextObject : IJsonModel { - internal partial class InternalMessageDeltaContentTextObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteObjectValue(Text, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(Text, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentTextObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentTextObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentTextObject DeserializeInternalMessageDeltaContentTextObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentTextObject(document.RootElement, options); + } + + internal static InternalMessageDeltaContentTextObject DeserializeInternalMessageDeltaContentTextObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + InternalMessageDeltaContentTextObjectText text = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - InternalMessageDeltaContentTextObjectText text = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("text"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("text"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - text = InternalMessageDeltaContentTextObjectText.DeserializeInternalMessageDeltaContentTextObjectText(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + text = InternalMessageDeltaContentTextObjectText.DeserializeInternalMessageDeltaContentTextObjectText(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextObject(type, serializedAdditionalRawData, index, text); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalMessageDeltaContentTextObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentTextObject(type, serializedAdditionalRawData, index, text); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageDeltaContentTextObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaContentTextObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentTextObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageDeltaContentTextObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentTextObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextObject.cs b/src/Generated/Models/InternalMessageDeltaContentTextObject.cs index a4154f43..f54933a4 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextObject.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextObject.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextObject : InternalMessageDeltaContent { - internal partial class InternalMessageDeltaContentTextObject : InternalMessageDeltaContent + internal InternalMessageDeltaContentTextObject(int index) { - internal InternalMessageDeltaContentTextObject(int index) - { - Type = "text"; - Index = index; - } - - internal InternalMessageDeltaContentTextObject(string type, IDictionary serializedAdditionalRawData, int index, InternalMessageDeltaContentTextObjectText text) : base(type, serializedAdditionalRawData) - { - Index = index; - Text = text; - } + Type = "text"; + Index = index; + } - internal InternalMessageDeltaContentTextObject() - { - } + internal InternalMessageDeltaContentTextObject(string type, IDictionary serializedAdditionalRawData, int index, InternalMessageDeltaContentTextObjectText text) : base(type, serializedAdditionalRawData) + { + Index = index; + Text = text; + } - public int Index { get; } - public InternalMessageDeltaContentTextObjectText Text { get; } + internal InternalMessageDeltaContentTextObject() + { } -} + + public int Index { get; } + public InternalMessageDeltaContentTextObjectText Text { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextObjectText.Serialization.cs b/src/Generated/Models/InternalMessageDeltaContentTextObjectText.Serialization.cs index fbc18edf..e4546a55 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextObjectText.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextObjectText.Serialization.cs @@ -8,151 +8,150 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextObjectText : IJsonModel { - internal partial class InternalMessageDeltaContentTextObjectText : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("value") != true && Optional.IsDefined(Value)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("value") != true && Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (SerializedAdditionalRawData?.ContainsKey("annotations") != true && Optional.IsCollectionDefined(Annotations)) + { + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (var item in Annotations) { - writer.WritePropertyName("value"u8); - writer.WriteStringValue(Value); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("annotations") != true && Optional.IsCollectionDefined(Annotations)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("annotations"u8); - writer.WriteStartArray(); - foreach (var item in Annotations) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaContentTextObjectText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaContentTextObjectText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextObjectText(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaContentTextObjectText DeserializeInternalMessageDeltaContentTextObjectText(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContentTextObjectText(document.RootElement, options); + } + + internal static InternalMessageDeltaContentTextObjectText DeserializeInternalMessageDeltaContentTextObjectText(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + IReadOnlyList annotations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) { - return null; + value = property.Value.GetString(); + continue; } - string value = default; - IReadOnlyList annotations = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("annotations"u8)) { - if (property.NameEquals("value"u8)) - { - value = property.Value.GetString(); - continue; - } - if (property.NameEquals("annotations"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalMessageDeltaTextContentAnnotation.DeserializeInternalMessageDeltaTextContentAnnotation(item, options)); - } - annotations = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalMessageDeltaTextContentAnnotation.DeserializeInternalMessageDeltaTextContentAnnotation(item, options)); } + annotations = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextObjectText(value, annotations ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaContentTextObjectText(value, annotations ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalMessageDeltaContentTextObjectText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextObjectText(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageDeltaContentTextObjectText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaContentTextObjectText FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextObjectText(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContentTextObjectText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextObjectText)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaContentTextObjectText FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaContentTextObjectText(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaContentTextObjectText.cs b/src/Generated/Models/InternalMessageDeltaContentTextObjectText.cs index f2b65143..f6e5baed 100644 --- a/src/Generated/Models/InternalMessageDeltaContentTextObjectText.cs +++ b/src/Generated/Models/InternalMessageDeltaContentTextObjectText.cs @@ -5,24 +5,23 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaContentTextObjectText { - internal partial class InternalMessageDeltaContentTextObjectText + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageDeltaContentTextObjectText() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageDeltaContentTextObjectText() - { - Annotations = new ChangeTrackingList(); - } - - internal InternalMessageDeltaContentTextObjectText(string value, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) - { - Value = value; - Annotations = annotations; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Annotations = new ChangeTrackingList(); + } - public string Value { get; } - public IReadOnlyList Annotations { get; } + internal InternalMessageDeltaContentTextObjectText(string value, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) + { + Value = value; + Annotations = annotations; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Value { get; } + public IReadOnlyList Annotations { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaObject.Serialization.cs b/src/Generated/Models/InternalMessageDeltaObject.Serialization.cs index 1bba6540..80aaf1fb 100644 --- a/src/Generated/Models/InternalMessageDeltaObject.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaObject.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaObject : IJsonModel { - internal partial class InternalMessageDeltaObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("delta") != true) - { - writer.WritePropertyName("delta"u8); - writer.WriteObjectValue(Delta, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("delta") != true) + { + writer.WritePropertyName("delta"u8); + writer.WriteObjectValue(Delta, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaObject DeserializeInternalMessageDeltaObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaObject(document.RootElement, options); + } + + internal static InternalMessageDeltaObject DeserializeInternalMessageDeltaObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalMessageDeltaObjectObject @object = default; + InternalMessageDeltaObjectDelta delta = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalMessageDeltaObjectObject @object = default; - InternalMessageDeltaObjectDelta delta = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalMessageDeltaObjectObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("delta"u8)) - { - delta = InternalMessageDeltaObjectDelta.DeserializeInternalMessageDeltaObjectDelta(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + @object = new InternalMessageDeltaObjectObject(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaObject(id, @object, delta, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("delta"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support writing '{options.Format}' format."); + delta = InternalMessageDeltaObjectDelta.DeserializeInternalMessageDeltaObjectDelta(property.Value, options); + continue; } - } - - InternalMessageDeltaObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaObject(id, @object, delta, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaObject(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaObject.cs b/src/Generated/Models/InternalMessageDeltaObject.cs index 92dad3ab..f2e584e7 100644 --- a/src/Generated/Models/InternalMessageDeltaObject.cs +++ b/src/Generated/Models/InternalMessageDeltaObject.cs @@ -5,35 +5,34 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaObject { - internal partial class InternalMessageDeltaObject + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageDeltaObject(string id, InternalMessageDeltaObjectDelta delta) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(delta, nameof(delta)); + + Id = id; + Delta = delta; + } + + internal InternalMessageDeltaObject(string id, InternalMessageDeltaObjectObject @object, InternalMessageDeltaObjectDelta delta, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageDeltaObject(string id, InternalMessageDeltaObjectDelta delta) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(delta, nameof(delta)); - - Id = id; - Delta = delta; - } - - internal InternalMessageDeltaObject(string id, InternalMessageDeltaObjectObject @object, InternalMessageDeltaObjectDelta delta, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - Delta = delta; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalMessageDeltaObject() - { - } - - public string Id { get; } - public InternalMessageDeltaObjectObject Object { get; } = InternalMessageDeltaObjectObject.ThreadMessageDelta; - - public InternalMessageDeltaObjectDelta Delta { get; } + Id = id; + Object = @object; + Delta = delta; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalMessageDeltaObject() + { + } + + public string Id { get; } + public InternalMessageDeltaObjectObject Object { get; } = InternalMessageDeltaObjectObject.ThreadMessageDelta; + + public InternalMessageDeltaObjectDelta Delta { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaObjectDelta.Serialization.cs b/src/Generated/Models/InternalMessageDeltaObjectDelta.Serialization.cs index 93e19568..1194b959 100644 --- a/src/Generated/Models/InternalMessageDeltaObjectDelta.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaObjectDelta.Serialization.cs @@ -8,155 +8,154 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaObjectDelta : IJsonModel { - internal partial class InternalMessageDeltaObjectDelta : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("role") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("role") != true) + { + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("content") != true && Optional.IsCollectionDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) { - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("content") != true && Optional.IsCollectionDefined(Content)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (var item in Content) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaObjectDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaObjectDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaObjectDelta(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaObjectDelta DeserializeInternalMessageDeltaObjectDelta(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaObjectDelta(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageRole role = default; - IReadOnlyList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalMessageDeltaObjectDelta DeserializeInternalMessageDeltaObjectDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + IReadOnlyList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("role"u8)) { - if (property.NameEquals("role"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - role = property.Value.GetString().ToMessageRole(); continue; } - if (property.NameEquals("content"u8)) + role = property.Value.GetString().ToMessageRole(); + continue; + } + if (property.NameEquals("content"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalMessageDeltaContent.DeserializeInternalMessageDeltaContent(item, options)); - } - content = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalMessageDeltaContent.DeserializeInternalMessageDeltaContent(item, options)); } + content = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaObjectDelta(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageDeltaObjectDelta(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalMessageDeltaObjectDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaObjectDelta(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageDeltaObjectDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaObjectDelta FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaObjectDelta(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaObjectDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaObjectDelta)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaObjectDelta FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaObjectDelta(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaObjectDelta.cs b/src/Generated/Models/InternalMessageDeltaObjectDelta.cs index 63a7af93..9805ecaa 100644 --- a/src/Generated/Models/InternalMessageDeltaObjectDelta.cs +++ b/src/Generated/Models/InternalMessageDeltaObjectDelta.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageDeltaObjectDelta { - internal partial class InternalMessageDeltaObjectDelta + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageDeltaObjectDelta() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageDeltaObjectDelta() - { - Content = new ChangeTrackingList(); - } + Content = new ChangeTrackingList(); + } - internal InternalMessageDeltaObjectDelta(MessageRole role, IReadOnlyList content, IDictionary serializedAdditionalRawData) - { - Role = role; - Content = content; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public IReadOnlyList Content { get; } + internal InternalMessageDeltaObjectDelta(MessageRole role, IReadOnlyList content, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public IReadOnlyList Content { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaObjectDeltaRole.cs b/src/Generated/Models/InternalMessageDeltaObjectDeltaRole.cs index d477fcb9..b329f5e8 100644 --- a/src/Generated/Models/InternalMessageDeltaObjectDeltaRole.cs +++ b/src/Generated/Models/InternalMessageDeltaObjectDeltaRole.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageDeltaObjectDeltaRole : IEquatable { - internal readonly partial struct InternalMessageDeltaObjectDeltaRole : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageDeltaObjectDeltaRole(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageDeltaObjectDeltaRole(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string UserValue = "user"; - private const string AssistantValue = "assistant"; + private const string UserValue = "user"; + private const string AssistantValue = "assistant"; - public static InternalMessageDeltaObjectDeltaRole User { get; } = new InternalMessageDeltaObjectDeltaRole(UserValue); - public static InternalMessageDeltaObjectDeltaRole Assistant { get; } = new InternalMessageDeltaObjectDeltaRole(AssistantValue); - public static bool operator ==(InternalMessageDeltaObjectDeltaRole left, InternalMessageDeltaObjectDeltaRole right) => left.Equals(right); - public static bool operator !=(InternalMessageDeltaObjectDeltaRole left, InternalMessageDeltaObjectDeltaRole right) => !left.Equals(right); - public static implicit operator InternalMessageDeltaObjectDeltaRole(string value) => new InternalMessageDeltaObjectDeltaRole(value); + public static InternalMessageDeltaObjectDeltaRole User { get; } = new InternalMessageDeltaObjectDeltaRole(UserValue); + public static InternalMessageDeltaObjectDeltaRole Assistant { get; } = new InternalMessageDeltaObjectDeltaRole(AssistantValue); + public static bool operator ==(InternalMessageDeltaObjectDeltaRole left, InternalMessageDeltaObjectDeltaRole right) => left.Equals(right); + public static bool operator !=(InternalMessageDeltaObjectDeltaRole left, InternalMessageDeltaObjectDeltaRole right) => !left.Equals(right); + public static implicit operator InternalMessageDeltaObjectDeltaRole(string value) => new InternalMessageDeltaObjectDeltaRole(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageDeltaObjectDeltaRole other && Equals(other); - public bool Equals(InternalMessageDeltaObjectDeltaRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageDeltaObjectDeltaRole other && Equals(other); + public bool Equals(InternalMessageDeltaObjectDeltaRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaObjectObject.cs b/src/Generated/Models/InternalMessageDeltaObjectObject.cs index a420957e..9cf23b32 100644 --- a/src/Generated/Models/InternalMessageDeltaObjectObject.cs +++ b/src/Generated/Models/InternalMessageDeltaObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageDeltaObjectObject : IEquatable { - internal readonly partial struct InternalMessageDeltaObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageDeltaObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageDeltaObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadMessageDeltaValue = "thread.message.delta"; + private const string ThreadMessageDeltaValue = "thread.message.delta"; - public static InternalMessageDeltaObjectObject ThreadMessageDelta { get; } = new InternalMessageDeltaObjectObject(ThreadMessageDeltaValue); - public static bool operator ==(InternalMessageDeltaObjectObject left, InternalMessageDeltaObjectObject right) => left.Equals(right); - public static bool operator !=(InternalMessageDeltaObjectObject left, InternalMessageDeltaObjectObject right) => !left.Equals(right); - public static implicit operator InternalMessageDeltaObjectObject(string value) => new InternalMessageDeltaObjectObject(value); + public static InternalMessageDeltaObjectObject ThreadMessageDelta { get; } = new InternalMessageDeltaObjectObject(ThreadMessageDeltaValue); + public static bool operator ==(InternalMessageDeltaObjectObject left, InternalMessageDeltaObjectObject right) => left.Equals(right); + public static bool operator !=(InternalMessageDeltaObjectObject left, InternalMessageDeltaObjectObject right) => !left.Equals(right); + public static implicit operator InternalMessageDeltaObjectObject(string value) => new InternalMessageDeltaObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageDeltaObjectObject other && Equals(other); - public bool Equals(InternalMessageDeltaObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageDeltaObjectObject other && Equals(other); + public bool Equals(InternalMessageDeltaObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.Serialization.cs b/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.Serialization.cs index 1382bacd..8a79b1c4 100644 --- a/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.Serialization.cs +++ b/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.Serialization.cs @@ -7,118 +7,117 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownMessageDeltaTextContentAnnotation))] +internal partial class InternalMessageDeltaTextContentAnnotation : IJsonModel { - [PersistableModelProxy(typeof(UnknownMessageDeltaTextContentAnnotation))] - internal partial class InternalMessageDeltaTextContentAnnotation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageDeltaTextContentAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageDeltaTextContentAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{format}' format."); } - internal static InternalMessageDeltaTextContentAnnotation DeserializeInternalMessageDeltaTextContentAnnotation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "file_citation": return InternalMessageDeltaContentTextAnnotationsFileCitationObject.DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(element, options); - case "file_path": return InternalMessageDeltaContentTextAnnotationsFilePathObject.DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(element, options); - } - } - return UnknownMessageDeltaTextContentAnnotation.DeserializeUnknownMessageDeltaTextContentAnnotation(element, options); - } + internal static InternalMessageDeltaTextContentAnnotation DeserializeInternalMessageDeltaTextContentAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalMessageDeltaTextContentAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{options.Format}' format."); + case "file_citation": return InternalMessageDeltaContentTextAnnotationsFileCitationObject.DeserializeInternalMessageDeltaContentTextAnnotationsFileCitationObject(element, options); + case "file_path": return InternalMessageDeltaContentTextAnnotationsFilePathObject.DeserializeInternalMessageDeltaContentTextAnnotationsFilePathObject(element, options); } } + return UnknownMessageDeltaTextContentAnnotation.DeserializeUnknownMessageDeltaTextContentAnnotation(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageDeltaTextContentAnnotation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalMessageDeltaTextContentAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageDeltaTextContentAnnotation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.cs b/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.cs index 34640b4d..77c7b2c6 100644 --- a/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.cs +++ b/src/Generated/Models/InternalMessageDeltaTextContentAnnotation.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal abstract partial class InternalMessageDeltaTextContentAnnotation { - internal abstract partial class InternalMessageDeltaTextContentAnnotation + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalMessageDeltaTextContentAnnotation() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalMessageDeltaTextContentAnnotation() - { - } - - internal InternalMessageDeltaTextContentAnnotation(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalMessageDeltaTextContentAnnotation(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageImageFileContent.Serialization.cs b/src/Generated/Models/InternalMessageImageFileContent.Serialization.cs index 8a176fdb..6a6af8b1 100644 --- a/src/Generated/Models/InternalMessageImageFileContent.Serialization.cs +++ b/src/Generated/Models/InternalMessageImageFileContent.Serialization.cs @@ -8,96 +8,95 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageImageFileContent : IJsonModel { - internal partial class InternalMessageImageFileContent : IJsonModel + InternalMessageImageFileContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalMessageImageFileContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageImageFileContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageImageFileContent(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageImageFileContent)} does not support reading '{format}' format."); } - internal static InternalMessageImageFileContent DeserializeInternalMessageImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageImageFileContent(document.RootElement, options); + } + + internal static InternalMessageImageFileContent DeserializeInternalMessageImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + InternalMessageContentItemFileObjectImageFile imageFile = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetString(); + continue; } - string type = default; - InternalMessageContentItemFileObjectImageFile imageFile = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("image_file"u8)) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("image_file"u8)) - { - imageFile = InternalMessageContentItemFileObjectImageFile.DeserializeInternalMessageContentItemFileObjectImageFile(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + imageFile = InternalMessageContentItemFileObjectImageFile.DeserializeInternalMessageContentItemFileObjectImageFile(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageImageFileContent(serializedAdditionalRawData, type, imageFile); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageImageFileContent)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageImageFileContent(serializedAdditionalRawData, type, imageFile); + } - InternalMessageImageFileContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageImageFileContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageImageFileContent)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageImageFileContent)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageImageFileContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageImageFileContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageImageFileContent(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageImageFileContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageImageFileContent)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageImageFileContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageImageFileContent(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageImageFileContent.cs b/src/Generated/Models/InternalMessageImageFileContent.cs index 0daac586..1a345ff2 100644 --- a/src/Generated/Models/InternalMessageImageFileContent.cs +++ b/src/Generated/Models/InternalMessageImageFileContent.cs @@ -5,18 +5,17 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageImageFileContent : MessageContent { - internal partial class InternalMessageImageFileContent : MessageContent + internal InternalMessageImageFileContent(IDictionary serializedAdditionalRawData, string type, InternalMessageContentItemFileObjectImageFile imageFile) : base(serializedAdditionalRawData) { - internal InternalMessageImageFileContent(IDictionary serializedAdditionalRawData, string type, InternalMessageContentItemFileObjectImageFile imageFile) : base(serializedAdditionalRawData) - { - _type = type; - _imageFile = imageFile; - } + _type = type; + _imageFile = imageFile; + } - internal InternalMessageImageFileContent() - { - } + internal InternalMessageImageFileContent() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageImageUrlContent.Serialization.cs b/src/Generated/Models/InternalMessageImageUrlContent.Serialization.cs index bbf8977d..46c619ea 100644 --- a/src/Generated/Models/InternalMessageImageUrlContent.Serialization.cs +++ b/src/Generated/Models/InternalMessageImageUrlContent.Serialization.cs @@ -8,96 +8,95 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageImageUrlContent : IJsonModel { - internal partial class InternalMessageImageUrlContent : IJsonModel + InternalMessageImageUrlContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalMessageImageUrlContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageImageUrlContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageImageUrlContent(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageImageUrlContent)} does not support reading '{format}' format."); } - internal static InternalMessageImageUrlContent DeserializeInternalMessageImageUrlContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageImageUrlContent(document.RootElement, options); + } + + internal static InternalMessageImageUrlContent DeserializeInternalMessageImageUrlContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + InternalMessageContentImageUrlObjectImageUrl imageUrl = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetString(); + continue; } - string type = default; - InternalMessageContentImageUrlObjectImageUrl imageUrl = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("image_url"u8)) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("image_url"u8)) - { - imageUrl = InternalMessageContentImageUrlObjectImageUrl.DeserializeInternalMessageContentImageUrlObjectImageUrl(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + imageUrl = InternalMessageContentImageUrlObjectImageUrl.DeserializeInternalMessageContentImageUrlObjectImageUrl(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageImageUrlContent(serializedAdditionalRawData, type, imageUrl); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageImageUrlContent)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageImageUrlContent(serializedAdditionalRawData, type, imageUrl); + } - InternalMessageImageUrlContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageImageUrlContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageImageUrlContent)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageImageUrlContent)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageImageUrlContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageImageUrlContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageImageUrlContent(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageImageUrlContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageImageUrlContent)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageImageUrlContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageImageUrlContent(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageImageUrlContent.cs b/src/Generated/Models/InternalMessageImageUrlContent.cs index beb24948..9dc0253b 100644 --- a/src/Generated/Models/InternalMessageImageUrlContent.cs +++ b/src/Generated/Models/InternalMessageImageUrlContent.cs @@ -5,18 +5,17 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageImageUrlContent : MessageContent { - internal partial class InternalMessageImageUrlContent : MessageContent + internal InternalMessageImageUrlContent(IDictionary serializedAdditionalRawData, string type, InternalMessageContentImageUrlObjectImageUrl imageUrl) : base(serializedAdditionalRawData) { - internal InternalMessageImageUrlContent(IDictionary serializedAdditionalRawData, string type, InternalMessageContentImageUrlObjectImageUrl imageUrl) : base(serializedAdditionalRawData) - { - _type = type; - _imageUrl = imageUrl; - } + _type = type; + _imageUrl = imageUrl; + } - internal InternalMessageImageUrlContent() - { - } + internal InternalMessageImageUrlContent() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageObjectAttachment.Serialization.cs b/src/Generated/Models/InternalMessageObjectAttachment.Serialization.cs index 3d0849f9..3ec3d0df 100644 --- a/src/Generated/Models/InternalMessageObjectAttachment.Serialization.cs +++ b/src/Generated/Models/InternalMessageObjectAttachment.Serialization.cs @@ -8,170 +8,169 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageObjectAttachment : IJsonModel { - internal partial class InternalMessageObjectAttachment : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) + if (item == null) { - if (item == null) - { - writer.WriteNullValue(); - continue; - } + writer.WriteNullValue(); + continue; + } #if NET6_0_OR_GREATER writer.WriteRawValue(item); #else - using (JsonDocument document = JsonDocument.Parse(item)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - writer.WriteEndArray(); +#endif } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalMessageObjectAttachment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMessageObjectAttachment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageObjectAttachment(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support reading '{format}' format."); } - internal static InternalMessageObjectAttachment DeserializeInternalMessageObjectAttachment(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageObjectAttachment(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalMessageObjectAttachment DeserializeInternalMessageObjectAttachment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IReadOnlyList tools = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - return null; + fileId = property.Value.GetString(); + continue; } - string fileId = default; - IReadOnlyList tools = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("tools"u8)) { - if (property.NameEquals("file_id"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - fileId = property.Value.GetString(); continue; } - if (property.NameEquals("tools"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (item.ValueKind == JsonValueKind.Null) { - continue; + array.Add(null); } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + else { - if (item.ValueKind == JsonValueKind.Null) - { - array.Add(null); - } - else - { - array.Add(BinaryData.FromString(item.GetRawText())); - } + array.Add(BinaryData.FromString(item.GetRawText())); } - tools = array; - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } + tools = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageObjectAttachment(fileId, tools ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageObjectAttachment(fileId, tools ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalMessageObjectAttachment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageObjectAttachment(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageObjectAttachment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalMessageObjectAttachment FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageObjectAttachment(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageObjectAttachment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageObjectAttachment)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalMessageObjectAttachment FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageObjectAttachment(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageObjectAttachment.cs b/src/Generated/Models/InternalMessageObjectAttachment.cs index 1e92848e..cc0550de 100644 --- a/src/Generated/Models/InternalMessageObjectAttachment.cs +++ b/src/Generated/Models/InternalMessageObjectAttachment.cs @@ -5,24 +5,23 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageObjectAttachment { - internal partial class InternalMessageObjectAttachment + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalMessageObjectAttachment() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalMessageObjectAttachment() - { - Tools = new ChangeTrackingList(); - } - - internal InternalMessageObjectAttachment(string fileId, IReadOnlyList tools, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Tools = tools; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Tools = new ChangeTrackingList(); + } - public string FileId { get; } - public IReadOnlyList Tools { get; } + internal InternalMessageObjectAttachment(string fileId, IReadOnlyList tools, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Tools = tools; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string FileId { get; } + public IReadOnlyList Tools { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageObjectObject.cs b/src/Generated/Models/InternalMessageObjectObject.cs index e419910c..e59c8bb8 100644 --- a/src/Generated/Models/InternalMessageObjectObject.cs +++ b/src/Generated/Models/InternalMessageObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageObjectObject : IEquatable { - internal readonly partial struct InternalMessageObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadMessageValue = "thread.message"; + private const string ThreadMessageValue = "thread.message"; - public static InternalMessageObjectObject ThreadMessage { get; } = new InternalMessageObjectObject(ThreadMessageValue); - public static bool operator ==(InternalMessageObjectObject left, InternalMessageObjectObject right) => left.Equals(right); - public static bool operator !=(InternalMessageObjectObject left, InternalMessageObjectObject right) => !left.Equals(right); - public static implicit operator InternalMessageObjectObject(string value) => new InternalMessageObjectObject(value); + public static InternalMessageObjectObject ThreadMessage { get; } = new InternalMessageObjectObject(ThreadMessageValue); + public static bool operator ==(InternalMessageObjectObject left, InternalMessageObjectObject right) => left.Equals(right); + public static bool operator !=(InternalMessageObjectObject left, InternalMessageObjectObject right) => !left.Equals(right); + public static implicit operator InternalMessageObjectObject(string value) => new InternalMessageObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageObjectObject other && Equals(other); - public bool Equals(InternalMessageObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageObjectObject other && Equals(other); + public bool Equals(InternalMessageObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageObjectRole.cs b/src/Generated/Models/InternalMessageObjectRole.cs index 91e68a9d..ea3eb09a 100644 --- a/src/Generated/Models/InternalMessageObjectRole.cs +++ b/src/Generated/Models/InternalMessageObjectRole.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageObjectRole : IEquatable { - internal readonly partial struct InternalMessageObjectRole : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageObjectRole(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageObjectRole(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string UserValue = "user"; - private const string AssistantValue = "assistant"; + private const string UserValue = "user"; + private const string AssistantValue = "assistant"; - public static InternalMessageObjectRole User { get; } = new InternalMessageObjectRole(UserValue); - public static InternalMessageObjectRole Assistant { get; } = new InternalMessageObjectRole(AssistantValue); - public static bool operator ==(InternalMessageObjectRole left, InternalMessageObjectRole right) => left.Equals(right); - public static bool operator !=(InternalMessageObjectRole left, InternalMessageObjectRole right) => !left.Equals(right); - public static implicit operator InternalMessageObjectRole(string value) => new InternalMessageObjectRole(value); + public static InternalMessageObjectRole User { get; } = new InternalMessageObjectRole(UserValue); + public static InternalMessageObjectRole Assistant { get; } = new InternalMessageObjectRole(AssistantValue); + public static bool operator ==(InternalMessageObjectRole left, InternalMessageObjectRole right) => left.Equals(right); + public static bool operator !=(InternalMessageObjectRole left, InternalMessageObjectRole right) => !left.Equals(right); + public static implicit operator InternalMessageObjectRole(string value) => new InternalMessageObjectRole(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageObjectRole other && Equals(other); - public bool Equals(InternalMessageObjectRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageObjectRole other && Equals(other); + public bool Equals(InternalMessageObjectRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageRefusalContent.Serialization.cs b/src/Generated/Models/InternalMessageRefusalContent.Serialization.cs index 6e3c9846..a2eac2cf 100644 --- a/src/Generated/Models/InternalMessageRefusalContent.Serialization.cs +++ b/src/Generated/Models/InternalMessageRefusalContent.Serialization.cs @@ -8,96 +8,95 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageRefusalContent : IJsonModel { - internal partial class InternalMessageRefusalContent : IJsonModel + InternalMessageRefusalContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalMessageRefusalContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageRefusalContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageRefusalContent(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalMessageRefusalContent)} does not support reading '{format}' format."); } - internal static InternalMessageRefusalContent DeserializeInternalMessageRefusalContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageRefusalContent(document.RootElement, options); + } + + internal static InternalMessageRefusalContent DeserializeInternalMessageRefusalContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + string refusal = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetString(); + continue; } - string type = default; - string refusal = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("refusal"u8)) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("refusal"u8)) - { - refusal = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + refusal = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageRefusalContent(serializedAdditionalRawData, type, refusal); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageRefusalContent)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalMessageRefusalContent(serializedAdditionalRawData, type, refusal); + } - InternalMessageRefusalContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageRefusalContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageRefusalContent)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageRefusalContent)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalMessageRefusalContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalMessageRefusalContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageRefusalContent(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageRefusalContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageRefusalContent)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalMessageRefusalContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalMessageRefusalContent(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageRefusalContent.cs b/src/Generated/Models/InternalMessageRefusalContent.cs index dc6f0e0a..4a055f9c 100644 --- a/src/Generated/Models/InternalMessageRefusalContent.cs +++ b/src/Generated/Models/InternalMessageRefusalContent.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalMessageRefusalContent : MessageContent { - internal partial class InternalMessageRefusalContent : MessageContent + public InternalMessageRefusalContent(string internalRefusal) { - public InternalMessageRefusalContent(string internalRefusal) - { - Argument.AssertNotNull(internalRefusal, nameof(internalRefusal)); + Argument.AssertNotNull(internalRefusal, nameof(internalRefusal)); - InternalRefusal = internalRefusal; - } + InternalRefusal = internalRefusal; + } - internal InternalMessageRefusalContent(IDictionary serializedAdditionalRawData, string type, string internalRefusal) : base(serializedAdditionalRawData) - { - _type = type; - InternalRefusal = internalRefusal; - } + internal InternalMessageRefusalContent(IDictionary serializedAdditionalRawData, string type, string internalRefusal) : base(serializedAdditionalRawData) + { + _type = type; + InternalRefusal = internalRefusal; + } - internal InternalMessageRefusalContent() - { - } + internal InternalMessageRefusalContent() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalMessageRequestContentTextObjectType.cs b/src/Generated/Models/InternalMessageRequestContentTextObjectType.cs index f41f3c08..23f5c862 100644 --- a/src/Generated/Models/InternalMessageRequestContentTextObjectType.cs +++ b/src/Generated/Models/InternalMessageRequestContentTextObjectType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalMessageRequestContentTextObjectType : IEquatable { - internal readonly partial struct InternalMessageRequestContentTextObjectType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalMessageRequestContentTextObjectType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalMessageRequestContentTextObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TextValue = "text"; + private const string TextValue = "text"; - public static InternalMessageRequestContentTextObjectType Text { get; } = new InternalMessageRequestContentTextObjectType(TextValue); - public static bool operator ==(InternalMessageRequestContentTextObjectType left, InternalMessageRequestContentTextObjectType right) => left.Equals(right); - public static bool operator !=(InternalMessageRequestContentTextObjectType left, InternalMessageRequestContentTextObjectType right) => !left.Equals(right); - public static implicit operator InternalMessageRequestContentTextObjectType(string value) => new InternalMessageRequestContentTextObjectType(value); + public static InternalMessageRequestContentTextObjectType Text { get; } = new InternalMessageRequestContentTextObjectType(TextValue); + public static bool operator ==(InternalMessageRequestContentTextObjectType left, InternalMessageRequestContentTextObjectType right) => left.Equals(right); + public static bool operator !=(InternalMessageRequestContentTextObjectType left, InternalMessageRequestContentTextObjectType right) => !left.Equals(right); + public static implicit operator InternalMessageRequestContentTextObjectType(string value) => new InternalMessageRequestContentTextObjectType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalMessageRequestContentTextObjectType other && Equals(other); - public bool Equals(InternalMessageRequestContentTextObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalMessageRequestContentTextObjectType other && Equals(other); + public bool Equals(InternalMessageRequestContentTextObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModelObject.cs b/src/Generated/Models/InternalModelObject.cs index 79b9cefa..6337901f 100644 --- a/src/Generated/Models/InternalModelObject.cs +++ b/src/Generated/Models/InternalModelObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Models +namespace OpenAI.Models; + +internal readonly partial struct InternalModelObject : IEquatable { - internal readonly partial struct InternalModelObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalModelObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalModelObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ModelValue = "model"; + private const string ModelValue = "model"; - public static InternalModelObject Model { get; } = new InternalModelObject(ModelValue); - public static bool operator ==(InternalModelObject left, InternalModelObject right) => left.Equals(right); - public static bool operator !=(InternalModelObject left, InternalModelObject right) => !left.Equals(right); - public static implicit operator InternalModelObject(string value) => new InternalModelObject(value); + public static InternalModelObject Model { get; } = new InternalModelObject(ModelValue); + public static bool operator ==(InternalModelObject left, InternalModelObject right) => left.Equals(right); + public static bool operator !=(InternalModelObject left, InternalModelObject right) => !left.Equals(right); + public static implicit operator InternalModelObject(string value) => new InternalModelObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalModelObject other && Equals(other); - public bool Equals(InternalModelObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalModelObject other && Equals(other); + public bool Equals(InternalModelObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyAssistantRequestToolResources.Serialization.cs b/src/Generated/Models/InternalModifyAssistantRequestToolResources.Serialization.cs index bb4a8961..619d2787 100644 --- a/src/Generated/Models/InternalModifyAssistantRequestToolResources.Serialization.cs +++ b/src/Generated/Models/InternalModifyAssistantRequestToolResources.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyAssistantRequestToolResources : IJsonModel { - internal partial class InternalModifyAssistantRequestToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalModifyAssistantRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalModifyAssistantRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalModifyAssistantRequestToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support reading '{format}' format."); } - internal static InternalModifyAssistantRequestToolResources DeserializeInternalModifyAssistantRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalModifyAssistantRequestToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalModifyAssistantRequestToolResourcesCodeInterpreter codeInterpreter = default; - InternalToolResourcesFileSearchIdsOnly fileSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalModifyAssistantRequestToolResources DeserializeInternalModifyAssistantRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalModifyAssistantRequestToolResourcesCodeInterpreter codeInterpreter = default; + InternalToolResourcesFileSearchIdsOnly fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("code_interpreter"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = InternalModifyAssistantRequestToolResourcesCodeInterpreter.DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(property.Value, options); continue; } - if (property.NameEquals("file_search"u8)) + codeInterpreter = InternalModifyAssistantRequestToolResourcesCodeInterpreter.DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = InternalToolResourcesFileSearchIdsOnly.DeserializeInternalToolResourcesFileSearchIdsOnly(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = InternalToolResourcesFileSearchIdsOnly.DeserializeInternalToolResourcesFileSearchIdsOnly(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalModifyAssistantRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalModifyAssistantRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); + } - InternalModifyAssistantRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalModifyAssistantRequestToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalModifyAssistantRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalModifyAssistantRequestToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalModifyAssistantRequestToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalModifyAssistantRequestToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalModifyAssistantRequestToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalModifyAssistantRequestToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyAssistantRequestToolResources.cs b/src/Generated/Models/InternalModifyAssistantRequestToolResources.cs index 3bcf4c24..6dadcdf0 100644 --- a/src/Generated/Models/InternalModifyAssistantRequestToolResources.cs +++ b/src/Generated/Models/InternalModifyAssistantRequestToolResources.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyAssistantRequestToolResources { - internal partial class InternalModifyAssistantRequestToolResources + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalModifyAssistantRequestToolResources() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalModifyAssistantRequestToolResources() - { - } - - internal InternalModifyAssistantRequestToolResources(InternalModifyAssistantRequestToolResourcesCodeInterpreter codeInterpreter, InternalToolResourcesFileSearchIdsOnly fileSearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalModifyAssistantRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } - public InternalToolResourcesFileSearchIdsOnly FileSearch { get; set; } + internal InternalModifyAssistantRequestToolResources(InternalModifyAssistantRequestToolResourcesCodeInterpreter codeInterpreter, InternalToolResourcesFileSearchIdsOnly fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalModifyAssistantRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } + public InternalToolResourcesFileSearchIdsOnly FileSearch { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.Serialization.cs index 2b3ea1d6..1d6732c6 100644 --- a/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyAssistantRequestToolResourcesCodeInterpreter : IJsonModel { - internal partial class InternalModifyAssistantRequestToolResourcesCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalModifyAssistantRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalModifyAssistantRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalModifyAssistantRequestToolResourcesCodeInterpreter DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalModifyAssistantRequestToolResourcesCodeInterpreter DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + fileIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalModifyAssistantRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalModifyAssistantRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalModifyAssistantRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalModifyAssistantRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalModifyAssistantRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalModifyAssistantRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalModifyAssistantRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalModifyAssistantRequestToolResourcesCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.cs b/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.cs index 1b253879..e10438dd 100644 --- a/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.cs +++ b/src/Generated/Models/InternalModifyAssistantRequestToolResourcesCodeInterpreter.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyAssistantRequestToolResourcesCodeInterpreter { - internal partial class InternalModifyAssistantRequestToolResourcesCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalModifyAssistantRequestToolResourcesCodeInterpreter() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalModifyAssistantRequestToolResourcesCodeInterpreter() - { - FileIds = new ChangeTrackingList(); - } - - internal InternalModifyAssistantRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + } - public IList FileIds { get; } + internal InternalModifyAssistantRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList FileIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyThreadRequestToolResources.Serialization.cs b/src/Generated/Models/InternalModifyThreadRequestToolResources.Serialization.cs index 3354accf..835d24cc 100644 --- a/src/Generated/Models/InternalModifyThreadRequestToolResources.Serialization.cs +++ b/src/Generated/Models/InternalModifyThreadRequestToolResources.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyThreadRequestToolResources : IJsonModel { - internal partial class InternalModifyThreadRequestToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalModifyThreadRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalModifyThreadRequestToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalModifyThreadRequestToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support reading '{format}' format."); } - internal static InternalModifyThreadRequestToolResources DeserializeInternalModifyThreadRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalModifyThreadRequestToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalModifyThreadRequestToolResourcesCodeInterpreter codeInterpreter = default; - InternalToolResourcesFileSearchIdsOnly fileSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalModifyThreadRequestToolResources DeserializeInternalModifyThreadRequestToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalModifyThreadRequestToolResourcesCodeInterpreter codeInterpreter = default; + InternalToolResourcesFileSearchIdsOnly fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("code_interpreter"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = InternalModifyThreadRequestToolResourcesCodeInterpreter.DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(property.Value, options); continue; } - if (property.NameEquals("file_search"u8)) + codeInterpreter = InternalModifyThreadRequestToolResourcesCodeInterpreter.DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = InternalToolResourcesFileSearchIdsOnly.DeserializeInternalToolResourcesFileSearchIdsOnly(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = InternalToolResourcesFileSearchIdsOnly.DeserializeInternalToolResourcesFileSearchIdsOnly(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalModifyThreadRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalModifyThreadRequestToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); + } - InternalModifyThreadRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalModifyThreadRequestToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalModifyThreadRequestToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalModifyThreadRequestToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalModifyThreadRequestToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalModifyThreadRequestToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalModifyThreadRequestToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalModifyThreadRequestToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyThreadRequestToolResources.cs b/src/Generated/Models/InternalModifyThreadRequestToolResources.cs index 0876ba2d..730d5dd3 100644 --- a/src/Generated/Models/InternalModifyThreadRequestToolResources.cs +++ b/src/Generated/Models/InternalModifyThreadRequestToolResources.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyThreadRequestToolResources { - internal partial class InternalModifyThreadRequestToolResources + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalModifyThreadRequestToolResources() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalModifyThreadRequestToolResources() - { - } - - internal InternalModifyThreadRequestToolResources(InternalModifyThreadRequestToolResourcesCodeInterpreter codeInterpreter, InternalToolResourcesFileSearchIdsOnly fileSearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalModifyThreadRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } - public InternalToolResourcesFileSearchIdsOnly FileSearch { get; set; } + internal InternalModifyThreadRequestToolResources(InternalModifyThreadRequestToolResourcesCodeInterpreter codeInterpreter, InternalToolResourcesFileSearchIdsOnly fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalModifyThreadRequestToolResourcesCodeInterpreter CodeInterpreter { get; set; } + public InternalToolResourcesFileSearchIdsOnly FileSearch { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.Serialization.cs index cc3aafd7..4ae3f8d9 100644 --- a/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyThreadRequestToolResourcesCodeInterpreter : IJsonModel { - internal partial class InternalModifyThreadRequestToolResourcesCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalModifyThreadRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalModifyThreadRequestToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalModifyThreadRequestToolResourcesCodeInterpreter DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalModifyThreadRequestToolResourcesCodeInterpreter DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + fileIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalModifyThreadRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalModifyThreadRequestToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalModifyThreadRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalModifyThreadRequestToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalModifyThreadRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalModifyThreadRequestToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalModifyThreadRequestToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalModifyThreadRequestToolResourcesCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.cs b/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.cs index df0ce6bf..17f008ea 100644 --- a/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.cs +++ b/src/Generated/Models/InternalModifyThreadRequestToolResourcesCodeInterpreter.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalModifyThreadRequestToolResourcesCodeInterpreter { - internal partial class InternalModifyThreadRequestToolResourcesCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalModifyThreadRequestToolResourcesCodeInterpreter() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalModifyThreadRequestToolResourcesCodeInterpreter() - { - FileIds = new ChangeTrackingList(); - } - - internal InternalModifyThreadRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + } - public IList FileIds { get; } + internal InternalModifyThreadRequestToolResourcesCodeInterpreter(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList FileIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalOmniTypedResponseFormat.Serialization.cs b/src/Generated/Models/InternalOmniTypedResponseFormat.Serialization.cs index 6ccf09de..651fd2a4 100644 --- a/src/Generated/Models/InternalOmniTypedResponseFormat.Serialization.cs +++ b/src/Generated/Models/InternalOmniTypedResponseFormat.Serialization.cs @@ -7,119 +7,118 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +[PersistableModelProxy(typeof(InternalUnknownOmniTypedResponseFormat))] +internal partial class InternalOmniTypedResponseFormat : IJsonModel { - [PersistableModelProxy(typeof(InternalUnknownOmniTypedResponseFormat))] - internal partial class InternalOmniTypedResponseFormat : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalOmniTypedResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalOmniTypedResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{format}' format."); } - internal static InternalOmniTypedResponseFormat DeserializeInternalOmniTypedResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "json_object": return InternalResponseFormatJsonObject.DeserializeInternalResponseFormatJsonObject(element, options); - case "json_schema": return InternalResponseFormatJsonSchema.DeserializeInternalResponseFormatJsonSchema(element, options); - case "text": return InternalResponseFormatText.DeserializeInternalResponseFormatText(element, options); - } - } - return InternalUnknownOmniTypedResponseFormat.DeserializeInternalUnknownOmniTypedResponseFormat(element, options); - } + internal static InternalOmniTypedResponseFormat DeserializeInternalOmniTypedResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalOmniTypedResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{options.Format}' format."); + case "json_object": return InternalResponseFormatJsonObject.DeserializeInternalResponseFormatJsonObject(element, options); + case "json_schema": return InternalResponseFormatJsonSchema.DeserializeInternalResponseFormatJsonSchema(element, options); + case "text": return InternalResponseFormatText.DeserializeInternalResponseFormatText(element, options); } } + return InternalUnknownOmniTypedResponseFormat.DeserializeInternalUnknownOmniTypedResponseFormat(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalOmniTypedResponseFormat FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalOmniTypedResponseFormat(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalOmniTypedResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalOmniTypedResponseFormat FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalOmniTypedResponseFormat(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalOmniTypedResponseFormat.cs b/src/Generated/Models/InternalOmniTypedResponseFormat.cs index da255f50..da252806 100644 --- a/src/Generated/Models/InternalOmniTypedResponseFormat.cs +++ b/src/Generated/Models/InternalOmniTypedResponseFormat.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal abstract partial class InternalOmniTypedResponseFormat { - internal abstract partial class InternalOmniTypedResponseFormat + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalOmniTypedResponseFormat() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalOmniTypedResponseFormat() - { - } - - internal InternalOmniTypedResponseFormat(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalOmniTypedResponseFormat(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalOpenAIFileObject.cs b/src/Generated/Models/InternalOpenAIFileObject.cs index d32ba177..6e66dfdd 100644 --- a/src/Generated/Models/InternalOpenAIFileObject.cs +++ b/src/Generated/Models/InternalOpenAIFileObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal readonly partial struct InternalOpenAIFileObject : IEquatable { - internal readonly partial struct InternalOpenAIFileObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalOpenAIFileObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalOpenAIFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FileValue = "file"; + private const string FileValue = "file"; - public static InternalOpenAIFileObject File { get; } = new InternalOpenAIFileObject(FileValue); - public static bool operator ==(InternalOpenAIFileObject left, InternalOpenAIFileObject right) => left.Equals(right); - public static bool operator !=(InternalOpenAIFileObject left, InternalOpenAIFileObject right) => !left.Equals(right); - public static implicit operator InternalOpenAIFileObject(string value) => new InternalOpenAIFileObject(value); + public static InternalOpenAIFileObject File { get; } = new InternalOpenAIFileObject(FileValue); + public static bool operator ==(InternalOpenAIFileObject left, InternalOpenAIFileObject right) => left.Equals(right); + public static bool operator !=(InternalOpenAIFileObject left, InternalOpenAIFileObject right) => !left.Equals(right); + public static implicit operator InternalOpenAIFileObject(string value) => new InternalOpenAIFileObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalOpenAIFileObject other && Equals(other); - public bool Equals(InternalOpenAIFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalOpenAIFileObject other && Equals(other); + public bool Equals(InternalOpenAIFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRequestMessageTextContent.Serialization.cs b/src/Generated/Models/InternalRequestMessageTextContent.Serialization.cs index abecb82d..b6637108 100644 --- a/src/Generated/Models/InternalRequestMessageTextContent.Serialization.cs +++ b/src/Generated/Models/InternalRequestMessageTextContent.Serialization.cs @@ -8,96 +8,95 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRequestMessageTextContent : IJsonModel { - internal partial class InternalRequestMessageTextContent : IJsonModel + InternalRequestMessageTextContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalRequestMessageTextContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRequestMessageTextContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRequestMessageTextContent(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRequestMessageTextContent)} does not support reading '{format}' format."); } - internal static InternalRequestMessageTextContent DeserializeInternalRequestMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRequestMessageTextContent(document.RootElement, options); + } + + internal static InternalRequestMessageTextContent DeserializeInternalRequestMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMessageRequestContentTextObjectType type = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = new InternalMessageRequestContentTextObjectType(property.Value.GetString()); + continue; } - InternalMessageRequestContentTextObjectType type = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("text"u8)) { - if (property.NameEquals("type"u8)) - { - type = new InternalMessageRequestContentTextObjectType(property.Value.GetString()); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + text = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRequestMessageTextContent(serializedAdditionalRawData, type, text); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRequestMessageTextContent)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRequestMessageTextContent(serializedAdditionalRawData, type, text); + } - InternalRequestMessageTextContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRequestMessageTextContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRequestMessageTextContent)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRequestMessageTextContent)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRequestMessageTextContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRequestMessageTextContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRequestMessageTextContent(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRequestMessageTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRequestMessageTextContent)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRequestMessageTextContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRequestMessageTextContent(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRequestMessageTextContent.cs b/src/Generated/Models/InternalRequestMessageTextContent.cs index 7fb763cb..fdef05ee 100644 --- a/src/Generated/Models/InternalRequestMessageTextContent.cs +++ b/src/Generated/Models/InternalRequestMessageTextContent.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRequestMessageTextContent : MessageContent { - internal partial class InternalRequestMessageTextContent : MessageContent + public InternalRequestMessageTextContent(string internalText) { - public InternalRequestMessageTextContent(string internalText) - { - Argument.AssertNotNull(internalText, nameof(internalText)); - - InternalText = internalText; - } + Argument.AssertNotNull(internalText, nameof(internalText)); - internal InternalRequestMessageTextContent(IDictionary serializedAdditionalRawData, InternalMessageRequestContentTextObjectType type, string internalText) : base(serializedAdditionalRawData) - { - Type = type; - InternalText = internalText; - } + InternalText = internalText; + } - internal InternalRequestMessageTextContent() - { - } + internal InternalRequestMessageTextContent(IDictionary serializedAdditionalRawData, InternalMessageRequestContentTextObjectType type, string internalText) : base(serializedAdditionalRawData) + { + Type = type; + InternalText = internalText; + } - public InternalMessageRequestContentTextObjectType Type { get; } = InternalMessageRequestContentTextObjectType.Text; + internal InternalRequestMessageTextContent() + { } -} + + public InternalMessageRequestContentTextObjectType Type { get; } = InternalMessageRequestContentTextObjectType.Text; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRequiredFunctionToolCall.Serialization.cs b/src/Generated/Models/InternalRequiredFunctionToolCall.Serialization.cs index ab8bbc81..b04c4197 100644 --- a/src/Generated/Models/InternalRequiredFunctionToolCall.Serialization.cs +++ b/src/Generated/Models/InternalRequiredFunctionToolCall.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRequiredFunctionToolCall : IJsonModel { - internal partial class InternalRequiredFunctionToolCall : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteObjectValue(_type, options); - } - if (SerializedAdditionalRawData?.ContainsKey("function") != true) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(_internalFunction, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteObjectValue(_type, options); + } + if (SerializedAdditionalRawData?.ContainsKey("function") != true) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(_internalFunction, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRequiredFunctionToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRequiredFunctionToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRequiredFunctionToolCall(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support reading '{format}' format."); } - internal static InternalRequiredFunctionToolCall DeserializeInternalRequiredFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRequiredFunctionToolCall(document.RootElement, options); + } + + internal static InternalRequiredFunctionToolCall DeserializeInternalRequiredFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + object type = default; + InternalRunToolCallObjectFunction function = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - object type = default; - InternalRunToolCallObjectFunction function = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetObject(); - continue; - } - if (property.NameEquals("function"u8)) - { - function = InternalRunToolCallObjectFunction.DeserializeInternalRunToolCallObjectFunction(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetObject(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRequiredFunctionToolCall(id, type, function, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("function"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support writing '{options.Format}' format."); + function = InternalRunToolCallObjectFunction.DeserializeInternalRunToolCallObjectFunction(property.Value, options); + continue; } - } - - InternalRequiredFunctionToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRequiredFunctionToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRequiredFunctionToolCall(id, type, function, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRequiredFunctionToolCall FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRequiredFunctionToolCall(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support writing '{options.Format}' format."); } + } + + InternalRequiredFunctionToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRequiredFunctionToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRequiredFunctionToolCall)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRequiredFunctionToolCall FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRequiredFunctionToolCall(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRequiredFunctionToolCall.cs b/src/Generated/Models/InternalRequiredFunctionToolCall.cs index 3d44b809..896dea58 100644 --- a/src/Generated/Models/InternalRequiredFunctionToolCall.cs +++ b/src/Generated/Models/InternalRequiredFunctionToolCall.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRequiredFunctionToolCall { - internal partial class InternalRequiredFunctionToolCall + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRequiredFunctionToolCall(string id, InternalRunToolCallObjectFunction internalFunction) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(internalFunction, nameof(internalFunction)); + + Id = id; + _internalFunction = internalFunction; + } + + internal InternalRequiredFunctionToolCall(string id, object type, InternalRunToolCallObjectFunction internalFunction, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRequiredFunctionToolCall(string id, InternalRunToolCallObjectFunction internalFunction) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(internalFunction, nameof(internalFunction)); - - Id = id; - _internalFunction = internalFunction; - } - - internal InternalRequiredFunctionToolCall(string id, object type, InternalRunToolCallObjectFunction internalFunction, IDictionary serializedAdditionalRawData) - { - Id = id; - _type = type; - _internalFunction = internalFunction; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalRequiredFunctionToolCall() - { - } - - public string Id { get; } + Id = id; + _type = type; + _internalFunction = internalFunction; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalRequiredFunctionToolCall() + { + } + + public string Id { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonObject.Serialization.cs b/src/Generated/Models/InternalResponseFormatJsonObject.Serialization.cs index 66e2b97f..5df65b23 100644 --- a/src/Generated/Models/InternalResponseFormatJsonObject.Serialization.cs +++ b/src/Generated/Models/InternalResponseFormatJsonObject.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonObject : IJsonModel { - internal partial class InternalResponseFormatJsonObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support writing '{format}' format."); } - InternalResponseFormatJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponseFormatJsonObject(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalResponseFormatJsonObject DeserializeInternalResponseFormatJsonObject(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalResponseFormatJsonObject(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalResponseFormatJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support reading '{format}' format."); } - InternalResponseFormatJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseFormatJsonObject(document.RootElement, options); + } + + internal static InternalResponseFormatJsonObject DeserializeInternalResponseFormatJsonObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalResponseFormatJsonObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalResponseFormatJsonObject(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalResponseFormatJsonObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponseFormatJsonObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support writing '{options.Format}' format."); } + } + + InternalResponseFormatJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalResponseFormatJsonObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalResponseFormatJsonObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalResponseFormatJsonObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonObject.cs b/src/Generated/Models/InternalResponseFormatJsonObject.cs index b62b1891..62feabc1 100644 --- a/src/Generated/Models/InternalResponseFormatJsonObject.cs +++ b/src/Generated/Models/InternalResponseFormatJsonObject.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonObject : InternalOmniTypedResponseFormat { - internal partial class InternalResponseFormatJsonObject : InternalOmniTypedResponseFormat + public InternalResponseFormatJsonObject() { - public InternalResponseFormatJsonObject() - { - Type = "json_object"; - } + Type = "json_object"; + } - internal InternalResponseFormatJsonObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalResponseFormatJsonObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonSchema.Serialization.cs b/src/Generated/Models/InternalResponseFormatJsonSchema.Serialization.cs index 1746508f..9fd2792d 100644 --- a/src/Generated/Models/InternalResponseFormatJsonSchema.Serialization.cs +++ b/src/Generated/Models/InternalResponseFormatJsonSchema.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonSchema : IJsonModel { - internal partial class InternalResponseFormatJsonSchema : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("json_schema") != true) - { - writer.WritePropertyName("json_schema"u8); - writer.WriteObjectValue(JsonSchema, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("json_schema") != true) + { + writer.WritePropertyName("json_schema"u8); + writer.WriteObjectValue(JsonSchema, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalResponseFormatJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponseFormatJsonSchema(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support reading '{format}' format."); } - internal static InternalResponseFormatJsonSchema DeserializeInternalResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseFormatJsonSchema(document.RootElement, options); + } + + internal static InternalResponseFormatJsonSchema DeserializeInternalResponseFormatJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponseFormatJsonSchemaJsonSchema jsonSchema = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("json_schema"u8)) { - return null; + jsonSchema = InternalResponseFormatJsonSchemaJsonSchema.DeserializeInternalResponseFormatJsonSchemaJsonSchema(property.Value, options); + continue; } - InternalResponseFormatJsonSchemaJsonSchema jsonSchema = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("json_schema"u8)) - { - jsonSchema = InternalResponseFormatJsonSchemaJsonSchema.DeserializeInternalResponseFormatJsonSchemaJsonSchema(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalResponseFormatJsonSchema(type, serializedAdditionalRawData, jsonSchema); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalResponseFormatJsonSchema(type, serializedAdditionalRawData, jsonSchema); + } - InternalResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalResponseFormatJsonSchema(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalResponseFormatJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalResponseFormatJsonSchema FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponseFormatJsonSchema(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalResponseFormatJsonSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchema)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalResponseFormatJsonSchema FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalResponseFormatJsonSchema(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonSchema.cs b/src/Generated/Models/InternalResponseFormatJsonSchema.cs index 739eb22b..7d750e7f 100644 --- a/src/Generated/Models/InternalResponseFormatJsonSchema.cs +++ b/src/Generated/Models/InternalResponseFormatJsonSchema.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonSchema : InternalOmniTypedResponseFormat { - internal partial class InternalResponseFormatJsonSchema : InternalOmniTypedResponseFormat + public InternalResponseFormatJsonSchema(InternalResponseFormatJsonSchemaJsonSchema jsonSchema) { - public InternalResponseFormatJsonSchema(InternalResponseFormatJsonSchemaJsonSchema jsonSchema) - { - Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); - - Type = "json_schema"; - JsonSchema = jsonSchema; - } + Argument.AssertNotNull(jsonSchema, nameof(jsonSchema)); - internal InternalResponseFormatJsonSchema(string type, IDictionary serializedAdditionalRawData, InternalResponseFormatJsonSchemaJsonSchema jsonSchema) : base(type, serializedAdditionalRawData) - { - JsonSchema = jsonSchema; - } + Type = "json_schema"; + JsonSchema = jsonSchema; + } - internal InternalResponseFormatJsonSchema() - { - } + internal InternalResponseFormatJsonSchema(string type, IDictionary serializedAdditionalRawData, InternalResponseFormatJsonSchemaJsonSchema jsonSchema) : base(type, serializedAdditionalRawData) + { + JsonSchema = jsonSchema; + } - public InternalResponseFormatJsonSchemaJsonSchema JsonSchema { get; set; } + internal InternalResponseFormatJsonSchema() + { } -} + + public InternalResponseFormatJsonSchemaJsonSchema JsonSchema { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.Serialization.cs b/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.Serialization.cs index 5b9c4d93..92054aad 100644 --- a/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.Serialization.cs +++ b/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.Serialization.cs @@ -8,182 +8,181 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonSchemaJsonSchema : IJsonModel { - internal partial class InternalResponseFormatJsonSchemaJsonSchema : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) - { - writer.WritePropertyName("description"u8); - writer.WriteStringValue(Description); - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData?.ContainsKey("schema") != true && Optional.IsDefined(Schema)) - { - writer.WritePropertyName("schema"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("description") != true && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("schema") != true && Optional.IsDefined(Schema)) + { + writer.WritePropertyName("schema"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Schema); #else - using (JsonDocument document = JsonDocument.Parse(Schema)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } + using (JsonDocument document = JsonDocument.Parse(Schema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } #endif + } + if (SerializedAdditionalRawData?.ContainsKey("strict") != true && Optional.IsDefined(Strict)) + { + if (Strict != null) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); } - if (SerializedAdditionalRawData?.ContainsKey("strict") != true && Optional.IsDefined(Strict)) + else { - if (Strict != null) - { - writer.WritePropertyName("strict"u8); - writer.WriteBooleanValue(Strict.Value); - } - else - { - writer.WriteNull("strict"); - } + writer.WriteNull("strict"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalResponseFormatJsonSchemaJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalResponseFormatJsonSchemaJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponseFormatJsonSchemaJsonSchema(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support reading '{format}' format."); } - internal static InternalResponseFormatJsonSchemaJsonSchema DeserializeInternalResponseFormatJsonSchemaJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseFormatJsonSchemaJsonSchema(document.RootElement, options); + } + + internal static InternalResponseFormatJsonSchemaJsonSchema DeserializeInternalResponseFormatJsonSchemaJsonSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + BinaryData schema = default; + bool? strict = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) { - return null; + description = property.Value.GetString(); + continue; } - string description = default; - string name = default; - BinaryData schema = default; - bool? strict = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("description"u8)) - { - description = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("schema"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("schema"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - schema = BinaryData.FromString(property.Value.GetRawText()); continue; } - if (property.NameEquals("strict"u8)) + schema = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("strict"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - strict = null; - continue; - } - strict = property.Value.GetBoolean(); + strict = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + strict = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalResponseFormatJsonSchemaJsonSchema(description, name, schema, strict, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalResponseFormatJsonSchemaJsonSchema(description, name, schema, strict, serializedAdditionalRawData); + } - InternalResponseFormatJsonSchemaJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalResponseFormatJsonSchemaJsonSchema(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalResponseFormatJsonSchemaJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalResponseFormatJsonSchemaJsonSchema FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponseFormatJsonSchemaJsonSchema(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalResponseFormatJsonSchemaJsonSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaJsonSchema)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalResponseFormatJsonSchemaJsonSchema FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalResponseFormatJsonSchemaJsonSchema(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.cs b/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.cs index 533d36db..18b7fc7a 100644 --- a/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.cs +++ b/src/Generated/Models/InternalResponseFormatJsonSchemaJsonSchema.cs @@ -5,33 +5,32 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonSchemaJsonSchema { - internal partial class InternalResponseFormatJsonSchemaJsonSchema + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalResponseFormatJsonSchemaJsonSchema(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + internal InternalResponseFormatJsonSchemaJsonSchema(string description, string name, BinaryData schema, bool? strict, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalResponseFormatJsonSchemaJsonSchema(string name) - { - Argument.AssertNotNull(name, nameof(name)); - - Name = name; - } - - internal InternalResponseFormatJsonSchemaJsonSchema(string description, string name, BinaryData schema, bool? strict, IDictionary serializedAdditionalRawData) - { - Description = description; - Name = name; - Schema = schema; - Strict = strict; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalResponseFormatJsonSchemaJsonSchema() - { - } - - public string Description { get; set; } - public string Name { get; set; } - public bool? Strict { get; set; } + Description = description; + Name = name; + Schema = schema; + Strict = strict; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalResponseFormatJsonSchemaJsonSchema() + { + } + + public string Description { get; set; } + public string Name { get; set; } + public bool? Strict { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.Serialization.cs b/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.Serialization.cs index d7791854..4eae2f8f 100644 --- a/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.Serialization.cs +++ b/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.Serialization.cs @@ -8,104 +8,103 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonSchemaSchema : IJsonModel { - internal partial class InternalResponseFormatJsonSchemaSchema : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - foreach (var item in AdditionalProperties) - { - writer.WritePropertyName(item.Key); + writer.WriteStartObject(); + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - writer.WriteEndObject(); +#endif } + writer.WriteEndObject(); + } - InternalResponseFormatJsonSchemaSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalResponseFormatJsonSchemaSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponseFormatJsonSchemaSchema(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support reading '{format}' format."); } - internal static InternalResponseFormatJsonSchemaSchema DeserializeInternalResponseFormatJsonSchemaSchema(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseFormatJsonSchemaSchema(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary additionalProperties = default; - Dictionary additionalPropertiesDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - additionalProperties = additionalPropertiesDictionary; - return new InternalResponseFormatJsonSchemaSchema(additionalProperties); - } + internal static InternalResponseFormatJsonSchemaSchema DeserializeInternalResponseFormatJsonSchemaSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalResponseFormatJsonSchemaSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + IDictionary additionalProperties = default; + Dictionary additionalPropertiesDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalResponseFormatJsonSchemaSchema(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support reading '{options.Format}' format."); - } + additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } + additionalProperties = additionalPropertiesDictionary; + return new InternalResponseFormatJsonSchemaSchema(additionalProperties); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalResponseFormatJsonSchemaSchema FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponseFormatJsonSchemaSchema(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalResponseFormatJsonSchemaSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalResponseFormatJsonSchemaSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseFormatJsonSchemaSchema)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalResponseFormatJsonSchemaSchema FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalResponseFormatJsonSchemaSchema(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.cs b/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.cs index d00500ad..3f64b45e 100644 --- a/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.cs +++ b/src/Generated/Models/InternalResponseFormatJsonSchemaSchema.cs @@ -5,20 +5,19 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatJsonSchemaSchema { - internal partial class InternalResponseFormatJsonSchemaSchema + public InternalResponseFormatJsonSchemaSchema() { - public InternalResponseFormatJsonSchemaSchema() - { - AdditionalProperties = new ChangeTrackingDictionary(); - } - - internal InternalResponseFormatJsonSchemaSchema(IDictionary additionalProperties) - { - AdditionalProperties = additionalProperties; - } + AdditionalProperties = new ChangeTrackingDictionary(); + } - public IDictionary AdditionalProperties { get; } + internal InternalResponseFormatJsonSchemaSchema(IDictionary additionalProperties) + { + AdditionalProperties = additionalProperties; } -} + + public IDictionary AdditionalProperties { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatText.Serialization.cs b/src/Generated/Models/InternalResponseFormatText.Serialization.cs index b213da2e..608b7789 100644 --- a/src/Generated/Models/InternalResponseFormatText.Serialization.cs +++ b/src/Generated/Models/InternalResponseFormatText.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatText : IJsonModel { - internal partial class InternalResponseFormatText : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support writing '{format}' format."); } - InternalResponseFormatText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponseFormatText(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalResponseFormatText DeserializeInternalResponseFormatText(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalResponseFormatText(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalResponseFormatText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support reading '{format}' format."); } - InternalResponseFormatText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseFormatText(document.RootElement, options); + } + + internal static InternalResponseFormatText DeserializeInternalResponseFormatText(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalResponseFormatText(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalResponseFormatText(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalResponseFormatText FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponseFormatText(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support writing '{options.Format}' format."); } + } + + InternalResponseFormatText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalResponseFormatText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseFormatText)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalResponseFormatText FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalResponseFormatText(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseFormatText.cs b/src/Generated/Models/InternalResponseFormatText.cs index efe4d6fc..91d266bf 100644 --- a/src/Generated/Models/InternalResponseFormatText.cs +++ b/src/Generated/Models/InternalResponseFormatText.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalResponseFormatText : InternalOmniTypedResponseFormat { - internal partial class InternalResponseFormatText : InternalOmniTypedResponseFormat + public InternalResponseFormatText() { - public InternalResponseFormatText() - { - Type = "text"; - } + Type = "text"; + } - internal InternalResponseFormatText(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalResponseFormatText(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseMessageTextContent.Serialization.cs b/src/Generated/Models/InternalResponseMessageTextContent.Serialization.cs index 4a89d038..35fbedaf 100644 --- a/src/Generated/Models/InternalResponseMessageTextContent.Serialization.cs +++ b/src/Generated/Models/InternalResponseMessageTextContent.Serialization.cs @@ -8,96 +8,95 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalResponseMessageTextContent : IJsonModel { - internal partial class InternalResponseMessageTextContent : IJsonModel + InternalResponseMessageTextContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - InternalResponseMessageTextContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalResponseMessageTextContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalResponseMessageTextContent(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalResponseMessageTextContent)} does not support reading '{format}' format."); } - internal static InternalResponseMessageTextContent DeserializeInternalResponseMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseMessageTextContent(document.RootElement, options); + } + + internal static InternalResponseMessageTextContent DeserializeInternalResponseMessageTextContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + InternalMessageContentTextObjectText text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetString(); + continue; } - string type = default; - InternalMessageContentTextObjectText text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("text"u8)) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = InternalMessageContentTextObjectText.DeserializeInternalMessageContentTextObjectText(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + text = InternalMessageContentTextObjectText.DeserializeInternalMessageContentTextObjectText(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalResponseMessageTextContent(serializedAdditionalRawData, type, text); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalResponseMessageTextContent)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalResponseMessageTextContent(serializedAdditionalRawData, type, text); + } - InternalResponseMessageTextContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalResponseMessageTextContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalResponseMessageTextContent)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalResponseMessageTextContent)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalResponseMessageTextContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalResponseMessageTextContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalResponseMessageTextContent(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalResponseMessageTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseMessageTextContent)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalResponseMessageTextContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalResponseMessageTextContent(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalResponseMessageTextContent.cs b/src/Generated/Models/InternalResponseMessageTextContent.cs index 83930eb9..babcea16 100644 --- a/src/Generated/Models/InternalResponseMessageTextContent.cs +++ b/src/Generated/Models/InternalResponseMessageTextContent.cs @@ -5,18 +5,17 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalResponseMessageTextContent : MessageContent { - internal partial class InternalResponseMessageTextContent : MessageContent + internal InternalResponseMessageTextContent(IDictionary serializedAdditionalRawData, string type, InternalMessageContentTextObjectText text) : base(serializedAdditionalRawData) { - internal InternalResponseMessageTextContent(IDictionary serializedAdditionalRawData, string type, InternalMessageContentTextObjectText text) : base(serializedAdditionalRawData) - { - _type = type; - _text = text; - } + _type = type; + _text = text; + } - internal InternalResponseMessageTextContent() - { - } + internal InternalResponseMessageTextContent() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunObjectObject.cs b/src/Generated/Models/InternalRunObjectObject.cs index 4f2c77d9..df756ffa 100644 --- a/src/Generated/Models/InternalRunObjectObject.cs +++ b/src/Generated/Models/InternalRunObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalRunObjectObject : IEquatable { - internal readonly partial struct InternalRunObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalRunObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalRunObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadRunValue = "thread.run"; + private const string ThreadRunValue = "thread.run"; - public static InternalRunObjectObject ThreadRun { get; } = new InternalRunObjectObject(ThreadRunValue); - public static bool operator ==(InternalRunObjectObject left, InternalRunObjectObject right) => left.Equals(right); - public static bool operator !=(InternalRunObjectObject left, InternalRunObjectObject right) => !left.Equals(right); - public static implicit operator InternalRunObjectObject(string value) => new InternalRunObjectObject(value); + public static InternalRunObjectObject ThreadRun { get; } = new InternalRunObjectObject(ThreadRunValue); + public static bool operator ==(InternalRunObjectObject left, InternalRunObjectObject right) => left.Equals(right); + public static bool operator !=(InternalRunObjectObject left, InternalRunObjectObject right) => !left.Equals(right); + public static implicit operator InternalRunObjectObject(string value) => new InternalRunObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRunObjectObject other && Equals(other); - public bool Equals(InternalRunObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRunObjectObject other && Equals(other); + public bool Equals(InternalRunObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.Serialization.cs b/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.Serialization.cs index cd924594..9a809327 100644 --- a/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.Serialization.cs +++ b/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.Serialization.cs @@ -8,136 +8,135 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunObjectRequiredActionSubmitToolOutputs : IJsonModel { - internal partial class InternalRunObjectRequiredActionSubmitToolOutputs : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true) + { + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) { - writer.WritePropertyName("tool_calls"u8); - writer.WriteStartArray(); - foreach (var item in ToolCalls) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunObjectRequiredActionSubmitToolOutputs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunObjectRequiredActionSubmitToolOutputs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support reading '{format}' format."); } - internal static InternalRunObjectRequiredActionSubmitToolOutputs DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList toolCalls = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalRunObjectRequiredActionSubmitToolOutputs DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_calls"u8)) { - if (property.NameEquals("tool_calls"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalRequiredFunctionToolCall.DeserializeInternalRequiredFunctionToolCall(item, options)); - } - toolCalls = array; - continue; - } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalRequiredFunctionToolCall.DeserializeInternalRequiredFunctionToolCall(item, options)); } + toolCalls = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunObjectRequiredActionSubmitToolOutputs(toolCalls, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunObjectRequiredActionSubmitToolOutputs(toolCalls, serializedAdditionalRawData); + } - InternalRunObjectRequiredActionSubmitToolOutputs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunObjectRequiredActionSubmitToolOutputs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunObjectRequiredActionSubmitToolOutputs FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunObjectRequiredActionSubmitToolOutputs)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunObjectRequiredActionSubmitToolOutputs FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.cs b/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.cs index 323fc341..ad2e18df 100644 --- a/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.cs +++ b/src/Generated/Models/InternalRunObjectRequiredActionSubmitToolOutputs.cs @@ -6,28 +6,27 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunObjectRequiredActionSubmitToolOutputs { - internal partial class InternalRunObjectRequiredActionSubmitToolOutputs + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunObjectRequiredActionSubmitToolOutputs(IEnumerable toolCalls) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunObjectRequiredActionSubmitToolOutputs(IEnumerable toolCalls) - { - Argument.AssertNotNull(toolCalls, nameof(toolCalls)); - - ToolCalls = toolCalls.ToList(); - } + Argument.AssertNotNull(toolCalls, nameof(toolCalls)); - internal InternalRunObjectRequiredActionSubmitToolOutputs(IReadOnlyList toolCalls, IDictionary serializedAdditionalRawData) - { - ToolCalls = toolCalls; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + ToolCalls = toolCalls.ToList(); + } - internal InternalRunObjectRequiredActionSubmitToolOutputs() - { - } + internal InternalRunObjectRequiredActionSubmitToolOutputs(IReadOnlyList toolCalls, IDictionary serializedAdditionalRawData) + { + ToolCalls = toolCalls; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public IReadOnlyList ToolCalls { get; } + internal InternalRunObjectRequiredActionSubmitToolOutputs() + { } -} + + public IReadOnlyList ToolCalls { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunObjectRequiredActionType.cs b/src/Generated/Models/InternalRunObjectRequiredActionType.cs index bd53c326..d1761283 100644 --- a/src/Generated/Models/InternalRunObjectRequiredActionType.cs +++ b/src/Generated/Models/InternalRunObjectRequiredActionType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalRunObjectRequiredActionType : IEquatable { - internal readonly partial struct InternalRunObjectRequiredActionType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalRunObjectRequiredActionType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalRunObjectRequiredActionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string SubmitToolOutputsValue = "submit_tool_outputs"; + private const string SubmitToolOutputsValue = "submit_tool_outputs"; - public static InternalRunObjectRequiredActionType SubmitToolOutputs { get; } = new InternalRunObjectRequiredActionType(SubmitToolOutputsValue); - public static bool operator ==(InternalRunObjectRequiredActionType left, InternalRunObjectRequiredActionType right) => left.Equals(right); - public static bool operator !=(InternalRunObjectRequiredActionType left, InternalRunObjectRequiredActionType right) => !left.Equals(right); - public static implicit operator InternalRunObjectRequiredActionType(string value) => new InternalRunObjectRequiredActionType(value); + public static InternalRunObjectRequiredActionType SubmitToolOutputs { get; } = new InternalRunObjectRequiredActionType(SubmitToolOutputsValue); + public static bool operator ==(InternalRunObjectRequiredActionType left, InternalRunObjectRequiredActionType right) => left.Equals(right); + public static bool operator !=(InternalRunObjectRequiredActionType left, InternalRunObjectRequiredActionType right) => !left.Equals(right); + public static implicit operator InternalRunObjectRequiredActionType(string value) => new InternalRunObjectRequiredActionType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRunObjectRequiredActionType other && Equals(other); - public bool Equals(InternalRunObjectRequiredActionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRunObjectRequiredActionType other && Equals(other); + public bool Equals(InternalRunObjectRequiredActionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunRequiredAction.Serialization.cs b/src/Generated/Models/InternalRunRequiredAction.Serialization.cs index 67fe40ab..788369eb 100644 --- a/src/Generated/Models/InternalRunRequiredAction.Serialization.cs +++ b/src/Generated/Models/InternalRunRequiredAction.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunRequiredAction : IJsonModel { - internal partial class InternalRunRequiredAction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteObjectValue(Type, options); - } - if (SerializedAdditionalRawData?.ContainsKey("submit_tool_outputs") != true) - { - writer.WritePropertyName("submit_tool_outputs"u8); - writer.WriteObjectValue(SubmitToolOutputs, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteObjectValue(Type, options); + } + if (SerializedAdditionalRawData?.ContainsKey("submit_tool_outputs") != true) + { + writer.WritePropertyName("submit_tool_outputs"u8); + writer.WriteObjectValue(SubmitToolOutputs, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunRequiredAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunRequiredAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunRequiredAction(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support reading '{format}' format."); } - internal static InternalRunRequiredAction DeserializeInternalRunRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunRequiredAction(document.RootElement, options); + } + + internal static InternalRunRequiredAction DeserializeInternalRunRequiredAction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + object type = default; + InternalRunObjectRequiredActionSubmitToolOutputs submitToolOutputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetObject(); + continue; } - object type = default; - InternalRunObjectRequiredActionSubmitToolOutputs submitToolOutputs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("submit_tool_outputs"u8)) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetObject(); - continue; - } - if (property.NameEquals("submit_tool_outputs"u8)) - { - submitToolOutputs = InternalRunObjectRequiredActionSubmitToolOutputs.DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + submitToolOutputs = InternalRunObjectRequiredActionSubmitToolOutputs.DeserializeInternalRunObjectRequiredActionSubmitToolOutputs(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunRequiredAction(type, submitToolOutputs, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunRequiredAction(type, submitToolOutputs, serializedAdditionalRawData); + } - InternalRunRequiredAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunRequiredAction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunRequiredAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunRequiredAction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunRequiredAction(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunRequiredAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunRequiredAction)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunRequiredAction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunRequiredAction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunRequiredAction.cs b/src/Generated/Models/InternalRunRequiredAction.cs index 627dd8b8..d88eba40 100644 --- a/src/Generated/Models/InternalRunRequiredAction.cs +++ b/src/Generated/Models/InternalRunRequiredAction.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunRequiredAction { - internal partial class InternalRunRequiredAction + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunRequiredAction(InternalRunObjectRequiredActionSubmitToolOutputs submitToolOutputs) + { + Argument.AssertNotNull(submitToolOutputs, nameof(submitToolOutputs)); + + SubmitToolOutputs = submitToolOutputs; + } + + internal InternalRunRequiredAction(object type, InternalRunObjectRequiredActionSubmitToolOutputs submitToolOutputs, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunRequiredAction(InternalRunObjectRequiredActionSubmitToolOutputs submitToolOutputs) - { - Argument.AssertNotNull(submitToolOutputs, nameof(submitToolOutputs)); - - SubmitToolOutputs = submitToolOutputs; - } - - internal InternalRunRequiredAction(object type, InternalRunObjectRequiredActionSubmitToolOutputs submitToolOutputs, IDictionary serializedAdditionalRawData) - { - Type = type; - SubmitToolOutputs = submitToolOutputs; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalRunRequiredAction() - { - } - - public InternalRunObjectRequiredActionSubmitToolOutputs SubmitToolOutputs { get; } + Type = type; + SubmitToolOutputs = submitToolOutputs; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalRunRequiredAction() + { + } + + public InternalRunObjectRequiredActionSubmitToolOutputs SubmitToolOutputs { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.Serialization.cs b/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.Serialization.cs index 84313365..c2464fcf 100644 --- a/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.Serialization.cs +++ b/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepCodeInterpreterLogOutput : IJsonModel { - internal partial class InternalRunStepCodeInterpreterLogOutput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("logs") != true) - { - writer.WritePropertyName("logs"u8); - writer.WriteStringValue(InternalLogs); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("logs") != true) + { + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(InternalLogs); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepCodeInterpreterLogOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepCodeInterpreterLogOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepCodeInterpreterLogOutput(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support reading '{format}' format."); } - internal static InternalRunStepCodeInterpreterLogOutput DeserializeInternalRunStepCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepCodeInterpreterLogOutput(document.RootElement, options); + } + + internal static InternalRunStepCodeInterpreterLogOutput DeserializeInternalRunStepCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string logs = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("logs"u8)) { - return null; + logs = property.Value.GetString(); + continue; } - string logs = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("logs"u8)) - { - logs = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepCodeInterpreterLogOutput(type, serializedAdditionalRawData, logs); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepCodeInterpreterLogOutput(type, serializedAdditionalRawData, logs); + } - InternalRunStepCodeInterpreterLogOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepCodeInterpreterLogOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepCodeInterpreterLogOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepCodeInterpreterLogOutput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepCodeInterpreterLogOutput(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepCodeInterpreterLogOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterLogOutput)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepCodeInterpreterLogOutput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepCodeInterpreterLogOutput(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.cs b/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.cs index a44f25f4..76f6aafa 100644 --- a/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.cs +++ b/src/Generated/Models/InternalRunStepCodeInterpreterLogOutput.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepCodeInterpreterLogOutput : RunStepCodeInterpreterOutput { - internal partial class InternalRunStepCodeInterpreterLogOutput : RunStepCodeInterpreterOutput + internal InternalRunStepCodeInterpreterLogOutput(string internalLogs) { - internal InternalRunStepCodeInterpreterLogOutput(string internalLogs) - { - Argument.AssertNotNull(internalLogs, nameof(internalLogs)); + Argument.AssertNotNull(internalLogs, nameof(internalLogs)); - Type = "logs"; - InternalLogs = internalLogs; - } + Type = "logs"; + InternalLogs = internalLogs; + } - internal InternalRunStepCodeInterpreterLogOutput(string type, IDictionary serializedAdditionalRawData, string internalLogs) : base(type, serializedAdditionalRawData) - { - InternalLogs = internalLogs; - } + internal InternalRunStepCodeInterpreterLogOutput(string type, IDictionary serializedAdditionalRawData, string internalLogs) : base(type, serializedAdditionalRawData) + { + InternalLogs = internalLogs; + } - internal InternalRunStepCodeInterpreterLogOutput() - { - } + internal InternalRunStepCodeInterpreterLogOutput() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.Serialization.cs b/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.Serialization.cs index af3e3f3f..1f3a73b9 100644 --- a/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.Serialization.cs +++ b/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepCodeInterpreterToolCallDetails : IJsonModel { - internal partial class InternalRunStepCodeInterpreterToolCallDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(_codeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(_codeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepCodeInterpreterToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepCodeInterpreterToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepCodeInterpreterToolCallDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support reading '{format}' format."); } - internal static InternalRunStepCodeInterpreterToolCallDetails DeserializeInternalRunStepCodeInterpreterToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepCodeInterpreterToolCallDetails(document.RootElement, options); + } + + internal static InternalRunStepCodeInterpreterToolCallDetails DeserializeInternalRunStepCodeInterpreterToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("code_interpreter"u8)) - { - codeInterpreter = InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + codeInterpreter = InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepCodeInterpreterToolCallDetails(type, serializedAdditionalRawData, id, codeInterpreter); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepCodeInterpreterToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepCodeInterpreterToolCallDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepCodeInterpreterToolCallDetails(type, serializedAdditionalRawData, id, codeInterpreter); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepCodeInterpreterToolCallDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepCodeInterpreterToolCallDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepCodeInterpreterToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepCodeInterpreterToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepCodeInterpreterToolCallDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepCodeInterpreterToolCallDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepCodeInterpreterToolCallDetails(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.cs b/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.cs index 0b72cde8..ef87a46b 100644 --- a/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.cs +++ b/src/Generated/Models/InternalRunStepCodeInterpreterToolCallDetails.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepCodeInterpreterToolCallDetails : RunStepToolCall { - internal partial class InternalRunStepCodeInterpreterToolCallDetails : RunStepToolCall + internal InternalRunStepCodeInterpreterToolCallDetails(string id, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(codeInterpreter, nameof(codeInterpreter)); + + Type = "code_interpreter"; + Id = id; + _codeInterpreter = codeInterpreter; + } + + internal InternalRunStepCodeInterpreterToolCallDetails(string type, IDictionary serializedAdditionalRawData, string id, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(type, serializedAdditionalRawData) { - internal InternalRunStepCodeInterpreterToolCallDetails(string id, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(codeInterpreter, nameof(codeInterpreter)); - - Type = "code_interpreter"; - Id = id; - _codeInterpreter = codeInterpreter; - } - - internal InternalRunStepCodeInterpreterToolCallDetails(string type, IDictionary serializedAdditionalRawData, string id, InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(type, serializedAdditionalRawData) - { - Id = id; - _codeInterpreter = codeInterpreter; - } - - internal InternalRunStepCodeInterpreterToolCallDetails() - { - } - - public string Id { get; } + Id = id; + _codeInterpreter = codeInterpreter; } -} + + internal InternalRunStepCodeInterpreterToolCallDetails() + { + } + + public string Id { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDelta.Serialization.cs b/src/Generated/Models/InternalRunStepDelta.Serialization.cs index 3b6d4446..c0d68926 100644 --- a/src/Generated/Models/InternalRunStepDelta.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDelta.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDelta : IJsonModel { - internal partial class InternalRunStepDelta : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteObjectValue(Object, options); - } - if (SerializedAdditionalRawData?.ContainsKey("delta") != true) - { - writer.WritePropertyName("delta"u8); - writer.WriteObjectValue(Delta, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteObjectValue(Object, options); + } + if (SerializedAdditionalRawData?.ContainsKey("delta") != true) + { + writer.WritePropertyName("delta"u8); + writer.WriteObjectValue(Delta, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDelta(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support reading '{format}' format."); } - internal static InternalRunStepDelta DeserializeInternalRunStepDelta(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDelta(document.RootElement, options); + } + + internal static InternalRunStepDelta DeserializeInternalRunStepDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + object @object = default; + InternalRunStepDeltaObjectDelta delta = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - object @object = default; - InternalRunStepDeltaObjectDelta delta = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = property.Value.GetObject(); - continue; - } - if (property.NameEquals("delta"u8)) - { - delta = InternalRunStepDeltaObjectDelta.DeserializeInternalRunStepDeltaObjectDelta(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + @object = property.Value.GetObject(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDelta(id, @object, delta, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("delta"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support writing '{options.Format}' format."); + delta = InternalRunStepDeltaObjectDelta.DeserializeInternalRunStepDeltaObjectDelta(property.Value, options); + continue; } - } - - InternalRunStepDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDelta(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDelta(id, @object, delta, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDelta FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDelta(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDelta)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDelta FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDelta(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDelta.cs b/src/Generated/Models/InternalRunStepDelta.cs index 55d73464..f8df2289 100644 --- a/src/Generated/Models/InternalRunStepDelta.cs +++ b/src/Generated/Models/InternalRunStepDelta.cs @@ -5,34 +5,33 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDelta { - internal partial class InternalRunStepDelta + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDelta(string id, InternalRunStepDeltaObjectDelta delta) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(delta, nameof(delta)); + + Id = id; + Delta = delta; + } + + internal InternalRunStepDelta(string id, object @object, InternalRunStepDeltaObjectDelta delta, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDelta(string id, InternalRunStepDeltaObjectDelta delta) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(delta, nameof(delta)); - - Id = id; - Delta = delta; - } - - internal InternalRunStepDelta(string id, object @object, InternalRunStepDeltaObjectDelta delta, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - Delta = delta; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalRunStepDelta() - { - } - - public string Id { get; } - - public InternalRunStepDeltaObjectDelta Delta { get; } + Id = id; + Object = @object; + Delta = delta; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalRunStepDelta() + { + } + + public string Id { get; } + + public InternalRunStepDeltaObjectDelta Delta { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaObjectDelta.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaObjectDelta.Serialization.cs index b3430a12..54cfc222 100644 --- a/src/Generated/Models/InternalRunStepDeltaObjectDelta.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaObjectDelta.Serialization.cs @@ -8,130 +8,129 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaObjectDelta : IJsonModel { - internal partial class InternalRunStepDeltaObjectDelta : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("step_details") != true && Optional.IsDefined(StepDetails)) - { - writer.WritePropertyName("step_details"u8); - writer.WriteObjectValue(StepDetails, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("step_details") != true && Optional.IsDefined(StepDetails)) + { + writer.WritePropertyName("step_details"u8); + writer.WriteObjectValue(StepDetails, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaObjectDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaObjectDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaObjectDelta(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaObjectDelta DeserializeInternalRunStepDeltaObjectDelta(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaObjectDelta(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalRunStepDeltaStepDetails stepDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalRunStepDeltaObjectDelta DeserializeInternalRunStepDeltaObjectDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepDeltaStepDetails stepDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("step_details"u8)) { - if (property.NameEquals("step_details"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - stepDetails = InternalRunStepDeltaStepDetails.DeserializeInternalRunStepDeltaStepDetails(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + stepDetails = InternalRunStepDeltaStepDetails.DeserializeInternalRunStepDeltaStepDetails(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaObjectDelta(stepDetails, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaObjectDelta(stepDetails, serializedAdditionalRawData); + } - InternalRunStepDeltaObjectDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaObjectDelta(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDeltaObjectDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDeltaObjectDelta FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaObjectDelta(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaObjectDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaObjectDelta)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDeltaObjectDelta FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaObjectDelta(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaObjectDelta.cs b/src/Generated/Models/InternalRunStepDeltaObjectDelta.cs index 1faf845d..3577bacb 100644 --- a/src/Generated/Models/InternalRunStepDeltaObjectDelta.cs +++ b/src/Generated/Models/InternalRunStepDeltaObjectDelta.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaObjectDelta { - internal partial class InternalRunStepDeltaObjectDelta + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDeltaObjectDelta() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDeltaObjectDelta() - { - } - - internal InternalRunStepDeltaObjectDelta(InternalRunStepDeltaStepDetails stepDetails, IDictionary serializedAdditionalRawData) - { - StepDetails = stepDetails; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalRunStepDeltaStepDetails StepDetails { get; } + internal InternalRunStepDeltaObjectDelta(InternalRunStepDeltaStepDetails stepDetails, IDictionary serializedAdditionalRawData) + { + StepDetails = stepDetails; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalRunStepDeltaStepDetails StepDetails { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaObjectObject.cs b/src/Generated/Models/InternalRunStepDeltaObjectObject.cs index ea17969d..97955588 100644 --- a/src/Generated/Models/InternalRunStepDeltaObjectObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalRunStepDeltaObjectObject : IEquatable { - internal readonly partial struct InternalRunStepDeltaObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalRunStepDeltaObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalRunStepDeltaObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; + private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; - public static InternalRunStepDeltaObjectObject ThreadRunStepDelta { get; } = new InternalRunStepDeltaObjectObject(ThreadRunStepDeltaValue); - public static bool operator ==(InternalRunStepDeltaObjectObject left, InternalRunStepDeltaObjectObject right) => left.Equals(right); - public static bool operator !=(InternalRunStepDeltaObjectObject left, InternalRunStepDeltaObjectObject right) => !left.Equals(right); - public static implicit operator InternalRunStepDeltaObjectObject(string value) => new InternalRunStepDeltaObjectObject(value); + public static InternalRunStepDeltaObjectObject ThreadRunStepDelta { get; } = new InternalRunStepDeltaObjectObject(ThreadRunStepDeltaValue); + public static bool operator ==(InternalRunStepDeltaObjectObject left, InternalRunStepDeltaObjectObject right) => left.Equals(right); + public static bool operator !=(InternalRunStepDeltaObjectObject left, InternalRunStepDeltaObjectObject right) => !left.Equals(right); + public static implicit operator InternalRunStepDeltaObjectObject(string value) => new InternalRunStepDeltaObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRunStepDeltaObjectObject other && Equals(other); - public bool Equals(InternalRunStepDeltaObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRunStepDeltaObjectObject other && Equals(other); + public bool Equals(InternalRunStepDeltaObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetails.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetails.Serialization.cs index 6ba369d0..72bbd1c1 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetails.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetails.Serialization.cs @@ -7,118 +7,117 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownRunStepDeltaStepDetails))] +internal partial class InternalRunStepDeltaStepDetails : IJsonModel { - [PersistableModelProxy(typeof(UnknownRunStepDeltaStepDetails))] - internal partial class InternalRunStepDeltaStepDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetails DeserializeInternalRunStepDeltaStepDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "message_creation": return InternalRunStepDeltaStepDetailsMessageCreationObject.DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(element, options); - case "tool_calls": return InternalRunStepDeltaStepDetailsToolCallsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(element, options); - } - } - return UnknownRunStepDeltaStepDetails.DeserializeUnknownRunStepDeltaStepDetails(element, options); - } + internal static InternalRunStepDeltaStepDetails DeserializeInternalRunStepDeltaStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalRunStepDeltaStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{options.Format}' format."); + case "message_creation": return InternalRunStepDeltaStepDetailsMessageCreationObject.DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(element, options); + case "tool_calls": return InternalRunStepDeltaStepDetailsToolCallsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(element, options); } } + return UnknownRunStepDeltaStepDetails.DeserializeUnknownRunStepDeltaStepDetails(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDeltaStepDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalRunStepDeltaStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDeltaStepDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetails.cs b/src/Generated/Models/InternalRunStepDeltaStepDetails.cs index 98788679..1f639046 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetails.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetails.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal abstract partial class InternalRunStepDeltaStepDetails { - internal abstract partial class InternalRunStepDeltaStepDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalRunStepDeltaStepDetails() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalRunStepDeltaStepDetails() - { - } - - internal InternalRunStepDeltaStepDetails(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalRunStepDeltaStepDetails(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.Serialization.cs index 0c082506..fda9ec5b 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.Serialization.cs @@ -8,141 +8,140 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsMessageCreationObject : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsMessageCreationObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("message_creation") != true && Optional.IsDefined(MessageCreation)) - { - writer.WritePropertyName("message_creation"u8); - writer.WriteObjectValue(MessageCreation, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("message_creation") != true && Optional.IsDefined(MessageCreation)) + { + writer.WritePropertyName("message_creation"u8); + writer.WriteObjectValue(MessageCreation, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsMessageCreationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsMessageCreationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsMessageCreationObject DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation messageCreation = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalRunStepDeltaStepDetailsMessageCreationObject DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation messageCreation = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_creation"u8)) { - if (property.NameEquals("message_creation"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - messageCreation = InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + messageCreation = InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsMessageCreationObject(type, serializedAdditionalRawData, messageCreation); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDeltaStepDetailsMessageCreationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsMessageCreationObject(type, serializedAdditionalRawData, messageCreation); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDeltaStepDetailsMessageCreationObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalRunStepDeltaStepDetailsMessageCreationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDeltaStepDetailsMessageCreationObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.cs index 0ee0b50a..a4a28833 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObject.cs @@ -5,20 +5,19 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsMessageCreationObject : InternalRunStepDeltaStepDetails { - internal partial class InternalRunStepDeltaStepDetailsMessageCreationObject : InternalRunStepDeltaStepDetails + internal InternalRunStepDeltaStepDetailsMessageCreationObject() { - internal InternalRunStepDeltaStepDetailsMessageCreationObject() - { - Type = "message_creation"; - } - - internal InternalRunStepDeltaStepDetailsMessageCreationObject(string type, IDictionary serializedAdditionalRawData, InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation messageCreation) : base(type, serializedAdditionalRawData) - { - MessageCreation = messageCreation; - } + Type = "message_creation"; + } - public InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation MessageCreation { get; } + internal InternalRunStepDeltaStepDetailsMessageCreationObject(string type, IDictionary serializedAdditionalRawData, InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation messageCreation) : base(type, serializedAdditionalRawData) + { + MessageCreation = messageCreation; } -} + + public InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation MessageCreation { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.Serialization.cs index 24e66035..bc94db64 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("message_id") != true && Optional.IsDefined(MessageId)) - { - writer.WritePropertyName("message_id"u8); - writer.WriteStringValue(MessageId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{format}' format."); } - InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("message_id") != true && Optional.IsDefined(MessageId)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); + writer.WritePropertyName("message_id"u8); + writer.WriteStringValue(MessageId); } - - internal static InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string messageId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("message_id"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - messageId = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(messageId, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{format}' format."); } - InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); + } + + internal static InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string messageId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_id"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{options.Format}' format."); + messageId = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(messageId, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.cs index 812f249c..509233af 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation { - internal partial class InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation() - { - } - - internal InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(string messageId, IDictionary serializedAdditionalRawData) - { - MessageId = messageId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string MessageId { get; } + internal InternalRunStepDeltaStepDetailsMessageCreationObjectMessageCreation(string messageId, IDictionary serializedAdditionalRawData) + { + MessageId = messageId; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string MessageId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.Serialization.cs index 0b67792c..63920d19 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.Serialization.cs @@ -8,163 +8,162 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObject : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsCodeObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsCodeObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsCodeObject DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalRunStepDeltaStepDetailsToolCallsCodeObject DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string id = default; + InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string id = default; - InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("id"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("code_interpreter"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("code_interpreter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + codeInterpreter = InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsCodeObject(type, serializedAdditionalRawData, index, id, codeInterpreter); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDeltaStepDetailsToolCallsCodeObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsCodeObject(type, serializedAdditionalRawData, index, id, codeInterpreter); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDeltaStepDetailsToolCallsCodeObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetailsToolCallsCodeObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDeltaStepDetailsToolCallsCodeObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.cs index ccd8ec23..6235e588 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObject.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject + internal InternalRunStepDeltaStepDetailsToolCallsCodeObject(int index) { - internal InternalRunStepDeltaStepDetailsToolCallsCodeObject(int index) - { - Type = "code_interpreter"; - Index = index; - } - - internal InternalRunStepDeltaStepDetailsToolCallsCodeObject(string type, IDictionary serializedAdditionalRawData, int index, string id, InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(type, serializedAdditionalRawData) - { - Index = index; - Id = id; - CodeInterpreter = codeInterpreter; - } + Type = "code_interpreter"; + Index = index; + } - internal InternalRunStepDeltaStepDetailsToolCallsCodeObject() - { - } + internal InternalRunStepDeltaStepDetailsToolCallsCodeObject(string type, IDictionary serializedAdditionalRawData, int index, string id, InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter codeInterpreter) : base(type, serializedAdditionalRawData) + { + Index = index; + Id = id; + CodeInterpreter = codeInterpreter; + } - public int Index { get; } - public string Id { get; } - public InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter CodeInterpreter { get; } + internal InternalRunStepDeltaStepDetailsToolCallsCodeObject() + { } -} + + public int Index { get; } + public string Id { get; } + public InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter CodeInterpreter { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs index a95a2785..64fda2d0 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs @@ -8,151 +8,150 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("input") != true && Optional.IsDefined(Input)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("input") != true && Optional.IsDefined(Input)) + { + writer.WritePropertyName("input"u8); + writer.WriteStringValue(Input); + } + if (SerializedAdditionalRawData?.ContainsKey("outputs") != true && Optional.IsCollectionDefined(Outputs)) + { + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (var item in Outputs) { - writer.WritePropertyName("input"u8); - writer.WriteStringValue(Input); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("outputs") != true && Optional.IsCollectionDefined(Outputs)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); + } + + internal static InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string input = default; + IReadOnlyList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input"u8)) { - return null; + input = property.Value.GetString(); + continue; } - string input = default; - IReadOnlyList outputs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("outputs"u8)) { - if (property.NameEquals("input"u8)) - { - input = property.Value.GetString(); - continue; - } - if (property.NameEquals("outputs"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepUpdateCodeInterpreterOutput.DeserializeRunStepUpdateCodeInterpreterOutput(item, options)); - } - outputs = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(RunStepUpdateCodeInterpreterOutput.DeserializeRunStepUpdateCodeInterpreterOutput(item, options)); } + outputs = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(input, outputs ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(input, outputs ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.cs index 2330d340..2e2f025b 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter.cs @@ -5,24 +5,23 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter() - { - Outputs = new ChangeTrackingList(); - } - - internal InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) - { - Input = input; - Outputs = outputs; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Outputs = new ChangeTrackingList(); + } - public string Input { get; } - public IReadOnlyList Outputs { get; } + internal InternalRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreter(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) + { + Input = input; + Outputs = outputs; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Input { get; } + public IReadOnlyList Outputs { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.Serialization.cs index 2e1725b5..079db365 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.Serialization.cs @@ -8,152 +8,151 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("image") != true && Optional.IsDefined(Image)) - { - writer.WritePropertyName("image"u8); - writer.WriteObjectValue(Image, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("image") != true && Optional.IsDefined(Image)) + { + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(Image, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); + } + + internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage image = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage image = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("image"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("image"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - image = InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + image = InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(type, serializedAdditionalRawData, index, image); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(type, serializedAdditionalRawData, index, image); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.cs index 26acd5b7..5319a962 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject : RunStepUpdateCodeInterpreterOutput { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject : RunStepUpdateCodeInterpreterOutput + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(int index) { - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(int index) - { - Type = "image"; - Index = index; - } - - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(string type, IDictionary serializedAdditionalRawData, int index, InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage image) : base(type, serializedAdditionalRawData) - { - Index = index; - Image = image; - } + Type = "image"; + Index = index; + } - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject() - { - } + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(string type, IDictionary serializedAdditionalRawData, int index, InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage image) : base(type, serializedAdditionalRawData) + { + Index = index; + Image = image; + } - public int Index { get; } - public InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage Image { get; } + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject() + { } -} + + public int Index { get; } + public InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage Image { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs index 9ad45a12..72407aca 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{format}' format."); } - InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true && Optional.IsDefined(FileId)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); } - - internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("file_id"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - fileId = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(fileId, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{format}' format."); } - InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); + } + + internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{options.Format}' format."); + fileId = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(fileId, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.cs index cd41fb9f..e6df6c03 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage() - { - } - - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string FileId { get; } + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectImage(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string FileId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.Serialization.cs index 0047ba1a..b0883e66 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("logs") != true && Optional.IsDefined(InternalLogs)) - { - writer.WritePropertyName("logs"u8); - writer.WriteStringValue(InternalLogs); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("logs") != true && Optional.IsDefined(InternalLogs)) + { + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(InternalLogs); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(document.RootElement, options); + } + + internal static InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string logs = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string logs = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("logs"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("logs"u8)) - { - logs = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + logs = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(type, serializedAdditionalRawData, index, logs); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(type, serializedAdditionalRawData, index, logs); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.cs index aa0e9501..a1a505bc 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.cs @@ -5,26 +5,25 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject : RunStepUpdateCodeInterpreterOutput { - internal partial class InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject : RunStepUpdateCodeInterpreterOutput + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(int index) { - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(int index) - { - Type = "logs"; - Index = index; - } - - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(string type, IDictionary serializedAdditionalRawData, int index, string internalLogs) : base(type, serializedAdditionalRawData) - { - Index = index; - InternalLogs = internalLogs; - } + Type = "logs"; + Index = index; + } - internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject() - { - } + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(string type, IDictionary serializedAdditionalRawData, int index, string internalLogs) : base(type, serializedAdditionalRawData) + { + Index = index; + InternalLogs = internalLogs; + } - public int Index { get; } + internal InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject() + { } -} + + public int Index { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs index 78a34b22..d86e88a2 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.Serialization.cs @@ -8,189 +8,188 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObject : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support writing '{format}' format."); + } + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true) + { + writer.WritePropertyName("file_search"u8); writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) + foreach (var item in FileSearch) { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true) - { - writer.WritePropertyName("file_search"u8); - writer.WriteStartObject(); - foreach (var item in FileSearch) + writer.WritePropertyName(item.Key); + if (item.Value == null) { - writer.WritePropertyName(item.Key); - if (item.Value == null) - { - writer.WriteNullValue(); - continue; - } + writer.WriteNullValue(); + continue; + } #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } - writer.WriteEndObject(); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); +#endif } - if (SerializedAdditionalRawData != null) + writer.WriteEndObject(); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsFileSearchObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsFileSearchObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsFileSearchObject DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalRunStepDeltaStepDetailsToolCallsFileSearchObject DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string id = default; + IReadOnlyDictionary fileSearch = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string id = default; - IReadOnlyDictionary fileSearch = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("id"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_search"u8)) + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("file_search"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + if (property0.Value.ValueKind == JsonValueKind.Null) { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - dictionary.Add(property0.Name, null); - } - else - { - dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); - } + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); } - fileSearch = dictionary; - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } + fileSearch = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(type, serializedAdditionalRawData, index, id, fileSearch); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDeltaStepDetailsToolCallsFileSearchObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(type, serializedAdditionalRawData, index, id, fileSearch); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDeltaStepDetailsToolCallsFileSearchObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalRunStepDeltaStepDetailsToolCallsFileSearchObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFileSearchObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDeltaStepDetailsToolCallsFileSearchObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs index e3db470b..984113ed 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject { - internal partial class InternalRunStepDeltaStepDetailsToolCallsFileSearchObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject + internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(int index, IReadOnlyDictionary fileSearch) + { + Argument.AssertNotNull(fileSearch, nameof(fileSearch)); + + Type = "file_search"; + Index = index; + FileSearch = fileSearch; + } + + internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(string type, IDictionary serializedAdditionalRawData, int index, string id, IReadOnlyDictionary fileSearch) : base(type, serializedAdditionalRawData) { - internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(int index, IReadOnlyDictionary fileSearch) - { - Argument.AssertNotNull(fileSearch, nameof(fileSearch)); - - Type = "file_search"; - Index = index; - FileSearch = fileSearch; - } - - internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject(string type, IDictionary serializedAdditionalRawData, int index, string id, IReadOnlyDictionary fileSearch) : base(type, serializedAdditionalRawData) - { - Index = index; - Id = id; - FileSearch = fileSearch; - } - - internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject() - { - } - - public int Index { get; } - public string Id { get; } - public IReadOnlyDictionary FileSearch { get; } + Index = index; + Id = id; + FileSearch = fileSearch; } -} + + internal InternalRunStepDeltaStepDetailsToolCallsFileSearchObject() + { + } + + public int Index { get; } + public string Id { get; } + public IReadOnlyDictionary FileSearch { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.Serialization.cs index 66776a57..f6c35f53 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.Serialization.cs @@ -8,163 +8,162 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObject : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("function") != true && Optional.IsDefined(Function)) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("function") != true && Optional.IsDefined(Function)) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsFunctionObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsFunctionObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsFunctionObject DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalRunStepDeltaStepDetailsToolCallsFunctionObject DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string id = default; + InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction function = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string id = default; - InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction function = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("id"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("function"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - function = InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("function"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + function = InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsFunctionObject(type, serializedAdditionalRawData, index, id, function); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDeltaStepDetailsToolCallsFunctionObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsFunctionObject(type, serializedAdditionalRawData, index, id, function); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDeltaStepDetailsToolCallsFunctionObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetailsToolCallsFunctionObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDeltaStepDetailsToolCallsFunctionObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.cs index e45ecae1..a59e7012 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObject.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject { - internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject + internal InternalRunStepDeltaStepDetailsToolCallsFunctionObject(int index) { - internal InternalRunStepDeltaStepDetailsToolCallsFunctionObject(int index) - { - Type = "function"; - Index = index; - } - - internal InternalRunStepDeltaStepDetailsToolCallsFunctionObject(string type, IDictionary serializedAdditionalRawData, int index, string id, InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction function) : base(type, serializedAdditionalRawData) - { - Index = index; - Id = id; - Function = function; - } + Type = "function"; + Index = index; + } - internal InternalRunStepDeltaStepDetailsToolCallsFunctionObject() - { - } + internal InternalRunStepDeltaStepDetailsToolCallsFunctionObject(string type, IDictionary serializedAdditionalRawData, int index, string id, InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction function) : base(type, serializedAdditionalRawData) + { + Index = index; + Id = id; + Function = function; + } - public int Index { get; } - public string Id { get; } - public InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction Function { get; } + internal InternalRunStepDeltaStepDetailsToolCallsFunctionObject() + { } -} + + public int Index { get; } + public string Id { get; } + public InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction Function { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.Serialization.cs index f96531c1..92f19b15 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.Serialization.cs @@ -8,160 +8,159 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true && Optional.IsDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (SerializedAdditionalRawData?.ContainsKey("output") != true && Optional.IsDefined(Output)) + { + if (Output != null) { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); } - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true && Optional.IsDefined(Arguments)) + else { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); + writer.WriteNull("output"); } - if (SerializedAdditionalRawData?.ContainsKey("output") != true && Optional.IsDefined(Output)) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Output != null) - { - writer.WritePropertyName("output"u8); - writer.WriteStringValue(Output); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("output"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); + } + + internal static InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - string arguments = default; - string output = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("arguments"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (property.NameEquals("output"u8)) + arguments = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - output = null; - continue; - } - output = property.Value.GetString(); + output = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + output = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(name, arguments, output, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(name, arguments, output, serializedAdditionalRawData); + } - InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.cs index e546c4f8..fac0533b 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction { - internal partial class InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction() - { - } - - internal InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(string name, string arguments, string output, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - Output = output; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string Name { get; } - public string Arguments { get; } - public string Output { get; } + internal InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction(string name, string arguments, string output, IDictionary serializedAdditionalRawData) + { + Name = name; + Arguments = arguments; + Output = output; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Name { get; } + public string Arguments { get; } + public string Output { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.Serialization.cs index b1ba9cfa..d0a44a24 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.Serialization.cs @@ -8,151 +8,150 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsObject : IJsonModel { - internal partial class InternalRunStepDeltaStepDetailsToolCallsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true && Optional.IsCollectionDefined(ToolCalls)) - { - writer.WritePropertyName("tool_calls"u8); - writer.WriteStartArray(); - foreach (var item in ToolCalls) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true && Optional.IsCollectionDefined(ToolCalls)) + { + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsObject DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList toolCalls = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalRunStepDeltaStepDetailsToolCallsObject DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_calls"u8)) { - if (property.NameEquals("tool_calls"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(item, options)); - } - toolCalls = array; continue; } - if (property.NameEquals("type"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(item, options)); } + toolCalls = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDeltaStepDetailsToolCallsObject(type, serializedAdditionalRawData, toolCalls ?? new ChangeTrackingList()); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDeltaStepDetailsToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDeltaStepDetailsToolCallsObject(type, serializedAdditionalRawData, toolCalls ?? new ChangeTrackingList()); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDeltaStepDetailsToolCallsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalRunStepDeltaStepDetailsToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDeltaStepDetailsToolCallsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.cs index bae1ef10..e28efef6 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObject.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDeltaStepDetailsToolCallsObject : InternalRunStepDeltaStepDetails { - internal partial class InternalRunStepDeltaStepDetailsToolCallsObject : InternalRunStepDeltaStepDetails + internal InternalRunStepDeltaStepDetailsToolCallsObject() { - internal InternalRunStepDeltaStepDetailsToolCallsObject() - { - Type = "tool_calls"; - ToolCalls = new ChangeTrackingList(); - } - - internal InternalRunStepDeltaStepDetailsToolCallsObject(string type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) - { - ToolCalls = toolCalls; - } + Type = "tool_calls"; + ToolCalls = new ChangeTrackingList(); + } - public IReadOnlyList ToolCalls { get; } + internal InternalRunStepDeltaStepDetailsToolCallsObject(string type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) + { + ToolCalls = toolCalls; } -} + + public IReadOnlyList ToolCalls { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs index f9aa10e1..06bab2de 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs @@ -7,119 +7,118 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject))] +internal partial class InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject : IJsonModel { - [PersistableModelProxy(typeof(UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject))] - internal partial class InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "code_interpreter": return InternalRunStepDeltaStepDetailsToolCallsCodeObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(element, options); - case "file_search": return InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(element, options); - case "function": return InternalRunStepDeltaStepDetailsToolCallsFunctionObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(element, options); - } - } - return UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.DeserializeUnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(element, options); - } + internal static InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{options.Format}' format."); - } + return null; } - - InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{options.Format}' format."); + case "code_interpreter": return InternalRunStepDeltaStepDetailsToolCallsCodeObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeObject(element, options); + case "file_search": return InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(element, options); + case "function": return InternalRunStepDeltaStepDetailsToolCallsFunctionObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsFunctionObject(element, options); } } + return UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.DeserializeUnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs index 55b7f0b4..9ad2b757 100644 --- a/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs +++ b/src/Generated/Models/InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal abstract partial class InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject { - internal abstract partial class InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject + internal IDictionary SerializedAdditionalRawData { get; set; } + protected InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject() - { - } - - internal InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.Serialization.cs index 8f037505..00115c72 100644 --- a/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsMessageCreationObject : IJsonModel { - internal partial class InternalRunStepDetailsMessageCreationObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("message_creation") != true) - { - writer.WritePropertyName("message_creation"u8); - writer.WriteObjectValue(_messageCreation, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("message_creation") != true) + { + writer.WritePropertyName("message_creation"u8); + writer.WriteObjectValue(_messageCreation, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsMessageCreationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsMessageCreationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsMessageCreationObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsMessageCreationObject DeserializeInternalRunStepDetailsMessageCreationObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsMessageCreationObject(document.RootElement, options); + } + + internal static InternalRunStepDetailsMessageCreationObject DeserializeInternalRunStepDetailsMessageCreationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepDetailsMessageCreationObjectMessageCreation messageCreation = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_creation"u8)) { - return null; + messageCreation = InternalRunStepDetailsMessageCreationObjectMessageCreation.DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(property.Value, options); + continue; } - InternalRunStepDetailsMessageCreationObjectMessageCreation messageCreation = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("message_creation"u8)) - { - messageCreation = InternalRunStepDetailsMessageCreationObjectMessageCreation.DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsMessageCreationObject(type, serializedAdditionalRawData, messageCreation); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsMessageCreationObject(type, serializedAdditionalRawData, messageCreation); + } - InternalRunStepDetailsMessageCreationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsMessageCreationObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDetailsMessageCreationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDetailsMessageCreationObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsMessageCreationObject(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsMessageCreationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObject)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDetailsMessageCreationObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsMessageCreationObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.cs b/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.cs index e3600849..84669715 100644 --- a/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.cs +++ b/src/Generated/Models/InternalRunStepDetailsMessageCreationObject.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsMessageCreationObject : RunStepDetails { - internal partial class InternalRunStepDetailsMessageCreationObject : RunStepDetails + internal InternalRunStepDetailsMessageCreationObject(InternalRunStepDetailsMessageCreationObjectMessageCreation messageCreation) { - internal InternalRunStepDetailsMessageCreationObject(InternalRunStepDetailsMessageCreationObjectMessageCreation messageCreation) - { - Argument.AssertNotNull(messageCreation, nameof(messageCreation)); + Argument.AssertNotNull(messageCreation, nameof(messageCreation)); - Type = "message_creation"; - _messageCreation = messageCreation; - } + Type = "message_creation"; + _messageCreation = messageCreation; + } - internal InternalRunStepDetailsMessageCreationObject(string type, IDictionary serializedAdditionalRawData, InternalRunStepDetailsMessageCreationObjectMessageCreation messageCreation) : base(type, serializedAdditionalRawData) - { - _messageCreation = messageCreation; - } + internal InternalRunStepDetailsMessageCreationObject(string type, IDictionary serializedAdditionalRawData, InternalRunStepDetailsMessageCreationObjectMessageCreation messageCreation) : base(type, serializedAdditionalRawData) + { + _messageCreation = messageCreation; + } - internal InternalRunStepDetailsMessageCreationObject() - { - } + internal InternalRunStepDetailsMessageCreationObject() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.Serialization.cs index 4f0ef204..d24a0a0f 100644 --- a/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsMessageCreationObjectMessageCreation : IJsonModel { - internal partial class InternalRunStepDetailsMessageCreationObjectMessageCreation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("message_id") != true) - { - writer.WritePropertyName("message_id"u8); - writer.WriteStringValue(MessageId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{format}' format."); } - InternalRunStepDetailsMessageCreationObjectMessageCreation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("message_id") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); + writer.WritePropertyName("message_id"u8); + writer.WriteStringValue(MessageId); } - - internal static InternalRunStepDetailsMessageCreationObjectMessageCreation DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string messageId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("message_id"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - messageId = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsMessageCreationObjectMessageCreation(messageId, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalRunStepDetailsMessageCreationObjectMessageCreation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{format}' format."); } - InternalRunStepDetailsMessageCreationObjectMessageCreation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); + } + + internal static InternalRunStepDetailsMessageCreationObjectMessageCreation DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string messageId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_id"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{options.Format}' format."); + messageId = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsMessageCreationObjectMessageCreation(messageId, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDetailsMessageCreationObjectMessageCreation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDetailsMessageCreationObjectMessageCreation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsMessageCreationObjectMessageCreation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDetailsMessageCreationObjectMessageCreation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsMessageCreationObjectMessageCreation(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.cs b/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.cs index b876ff8c..8c61fffc 100644 --- a/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.cs +++ b/src/Generated/Models/InternalRunStepDetailsMessageCreationObjectMessageCreation.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsMessageCreationObjectMessageCreation { - internal partial class InternalRunStepDetailsMessageCreationObjectMessageCreation + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDetailsMessageCreationObjectMessageCreation(string messageId) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDetailsMessageCreationObjectMessageCreation(string messageId) - { - Argument.AssertNotNull(messageId, nameof(messageId)); - - MessageId = messageId; - } + Argument.AssertNotNull(messageId, nameof(messageId)); - internal InternalRunStepDetailsMessageCreationObjectMessageCreation(string messageId, IDictionary serializedAdditionalRawData) - { - MessageId = messageId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + MessageId = messageId; + } - internal InternalRunStepDetailsMessageCreationObjectMessageCreation() - { - } + internal InternalRunStepDetailsMessageCreationObjectMessageCreation(string messageId, IDictionary serializedAdditionalRawData) + { + MessageId = messageId; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string MessageId { get; } + internal InternalRunStepDetailsMessageCreationObjectMessageCreation() + { } -} + + public string MessageId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs index d1550479..6d763e2b 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.Serialization.cs @@ -8,147 +8,146 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("input") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("input") != true) + { + writer.WritePropertyName("input"u8); + writer.WriteStringValue(Input); + } + if (SerializedAdditionalRawData?.ContainsKey("outputs") != true) + { + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (var item in Outputs) { - writer.WritePropertyName("input"u8); - writer.WriteStringValue(Input); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("outputs") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("outputs"u8); - writer.WriteStartArray(); - foreach (var item in Outputs) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); + } + + internal static InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string input = default; + IReadOnlyList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input"u8)) { - return null; + input = property.Value.GetString(); + continue; } - string input = default; - IReadOnlyList outputs = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("outputs"u8)) { - if (property.NameEquals("input"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - input = property.Value.GetString(); - continue; - } - if (property.NameEquals("outputs"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepCodeInterpreterOutput.DeserializeRunStepCodeInterpreterOutput(item, options)); - } - outputs = array; - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(RunStepCodeInterpreterOutput.DeserializeRunStepCodeInterpreterOutput(item, options)); } + outputs = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(input, outputs, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(input, outputs, serializedAdditionalRawData); + } - InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.cs index 2c309b66..187e869c 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter.cs @@ -6,32 +6,31 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter { - internal partial class InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(string input, IEnumerable outputs) + { + Argument.AssertNotNull(input, nameof(input)); + Argument.AssertNotNull(outputs, nameof(outputs)); + + Input = input; + Outputs = outputs.ToList(); + } + + internal InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(string input, IEnumerable outputs) - { - Argument.AssertNotNull(input, nameof(input)); - Argument.AssertNotNull(outputs, nameof(outputs)); - - Input = input; - Outputs = outputs.ToList(); - } - - internal InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) - { - Input = input; - Outputs = outputs; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter() - { - } - - public string Input { get; } - public IReadOnlyList Outputs { get; } + Input = input; + Outputs = outputs; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalRunStepDetailsToolCallsCodeObjectCodeInterpreter() + { + } + + public string Input { get; } + public IReadOnlyList Outputs { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.Serialization.cs index e0de2eb5..456a4cc9 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObject : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("image") != true) - { - writer.WritePropertyName("image"u8); - writer.WriteObjectValue(_image, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("image") != true) + { + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(_image, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsToolCallsCodeOutputImageObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsCodeOutputImageObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsToolCallsCodeOutputImageObject DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); + } + + internal static InternalRunStepDetailsToolCallsCodeOutputImageObject DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepDetailsToolCallsCodeOutputImageObjectImage image = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) { - return null; + image = InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(property.Value, options); + continue; } - InternalRunStepDetailsToolCallsCodeOutputImageObjectImage image = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("image"u8)) - { - image = InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsCodeOutputImageObject(type, serializedAdditionalRawData, image); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsCodeOutputImageObject(type, serializedAdditionalRawData, image); + } - InternalRunStepDetailsToolCallsCodeOutputImageObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDetailsToolCallsCodeOutputImageObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDetailsToolCallsCodeOutputImageObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObject)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDetailsToolCallsCodeOutputImageObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.cs index 2d12da18..ccdb8a70 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObject.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObject : RunStepCodeInterpreterOutput { - internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObject : RunStepCodeInterpreterOutput + internal InternalRunStepDetailsToolCallsCodeOutputImageObject(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage image) { - internal InternalRunStepDetailsToolCallsCodeOutputImageObject(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage image) - { - Argument.AssertNotNull(image, nameof(image)); + Argument.AssertNotNull(image, nameof(image)); - Type = "image"; - _image = image; - } + Type = "image"; + _image = image; + } - internal InternalRunStepDetailsToolCallsCodeOutputImageObject(string type, IDictionary serializedAdditionalRawData, InternalRunStepDetailsToolCallsCodeOutputImageObjectImage image) : base(type, serializedAdditionalRawData) - { - _image = image; - } + internal InternalRunStepDetailsToolCallsCodeOutputImageObject(string type, IDictionary serializedAdditionalRawData, InternalRunStepDetailsToolCallsCodeOutputImageObjectImage image) : base(type, serializedAdditionalRawData) + { + _image = image; + } - internal InternalRunStepDetailsToolCallsCodeOutputImageObject() - { - } + internal InternalRunStepDetailsToolCallsCodeOutputImageObject() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs index 6e6ffba6..78cd33b0 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObjectImage : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObjectImage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{format}' format."); } - InternalRunStepDetailsToolCallsCodeOutputImageObjectImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); } - - internal static InternalRunStepDetailsToolCallsCodeOutputImageObjectImage DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string fileId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("file_id"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - fileId = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsCodeOutputImageObjectImage(fileId, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsCodeOutputImageObjectImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{format}' format."); } - InternalRunStepDetailsToolCallsCodeOutputImageObjectImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); + } + + internal static InternalRunStepDetailsToolCallsCodeOutputImageObjectImage DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{options.Format}' format."); + fileId = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsCodeOutputImageObjectImage(fileId, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDetailsToolCallsCodeOutputImageObjectImage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDetailsToolCallsCodeOutputImageObjectImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsCodeOutputImageObjectImage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDetailsToolCallsCodeOutputImageObjectImage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObjectImage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.cs index 17afb007..268ee839 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsCodeOutputImageObjectImage.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObjectImage { - internal partial class InternalRunStepDetailsToolCallsCodeOutputImageObjectImage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDetailsToolCallsCodeOutputImageObjectImage(string fileId) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDetailsToolCallsCodeOutputImageObjectImage(string fileId) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; - } + Argument.AssertNotNull(fileId, nameof(fileId)); - internal InternalRunStepDetailsToolCallsCodeOutputImageObjectImage(string fileId, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileId = fileId; + } - internal InternalRunStepDetailsToolCallsCodeOutputImageObjectImage() - { - } + internal InternalRunStepDetailsToolCallsCodeOutputImageObjectImage(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public string FileId { get; } + internal InternalRunStepDetailsToolCallsCodeOutputImageObjectImage() + { } -} + + public string FileId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs index 4df4c496..5a8a72ce 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.Serialization.cs @@ -8,155 +8,154 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFileSearchObjectFileSearch : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsFileSearchObjectFileSearch : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("ranking_options") != true && Optional.IsDefined(RankingOptions)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("ranking_options") != true && Optional.IsDefined(RankingOptions)) + { + writer.WritePropertyName("ranking_options"u8); + writer.WriteObjectValue(RankingOptions, options); + } + if (SerializedAdditionalRawData?.ContainsKey("results") != true && Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) { - writer.WritePropertyName("ranking_options"u8); - writer.WriteObjectValue(RankingOptions, options); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("results") != true && Optional.IsCollectionDefined(Results)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("results"u8); - writer.WriteStartArray(); - foreach (var item in Results) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsToolCallsFileSearchObjectFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsFileSearchObjectFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsToolCallsFileSearchObjectFileSearch DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - FileSearchRankingOptions rankingOptions = default; - IReadOnlyList results = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalRunStepDetailsToolCallsFileSearchObjectFileSearch DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FileSearchRankingOptions rankingOptions = default; + IReadOnlyList results = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ranking_options"u8)) { - if (property.NameEquals("ranking_options"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); continue; } - if (property.NameEquals("results"u8)) + rankingOptions = FileSearchRankingOptions.DeserializeFileSearchRankingOptions(property.Value, options); + continue; + } + if (property.NameEquals("results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepFileSearchResult.DeserializeRunStepFileSearchResult(item, options)); - } - results = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(RunStepFileSearchResult.DeserializeRunStepFileSearchResult(item, options)); } + results = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsFileSearchObjectFileSearch(rankingOptions, results ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsFileSearchObjectFileSearch(rankingOptions, results ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalRunStepDetailsToolCallsFileSearchObjectFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDetailsToolCallsFileSearchObjectFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDetailsToolCallsFileSearchObjectFileSearch FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchObjectFileSearch)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDetailsToolCallsFileSearchObjectFileSearch FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.cs index e48b1ce8..3bf8d258 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFileSearchObjectFileSearch { - internal partial class InternalRunStepDetailsToolCallsFileSearchObjectFileSearch + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDetailsToolCallsFileSearchObjectFileSearch() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDetailsToolCallsFileSearchObjectFileSearch() - { - Results = new ChangeTrackingList(); - } + Results = new ChangeTrackingList(); + } - internal InternalRunStepDetailsToolCallsFileSearchObjectFileSearch(FileSearchRankingOptions rankingOptions, IReadOnlyList results, IDictionary serializedAdditionalRawData) - { - RankingOptions = rankingOptions; - Results = results; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public IReadOnlyList Results { get; } + internal InternalRunStepDetailsToolCallsFileSearchObjectFileSearch(FileSearchRankingOptions rankingOptions, IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + RankingOptions = rankingOptions; + Results = results; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public IReadOnlyList Results { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.Serialization.cs index 2d2fa16e..f6b007e5 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("ranker") != true) - { - writer.WritePropertyName("ranker"u8); - writer.WriteStringValue(Ranker.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("score_threshold") != true) - { - writer.WritePropertyName("score_threshold"u8); - writer.WriteNumberValue(ScoreThreshold); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("ranker") != true) + { + writer.WritePropertyName("ranker"u8); + writer.WriteStringValue(Ranker.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("score_threshold") != true) + { + writer.WritePropertyName("score_threshold"u8); + writer.WriteNumberValue(ScoreThreshold); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(document.RootElement, options); + } + + internal static InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker ranker = default; + float scoreThreshold = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ranker"u8)) { - return null; + ranker = new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(property.Value.GetString()); + continue; } - InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker ranker = default; - float scoreThreshold = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("score_threshold"u8)) { - if (property.NameEquals("ranker"u8)) - { - ranker = new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(property.Value.GetString()); - continue; - } - if (property.NameEquals("score_threshold"u8)) - { - scoreThreshold = property.Value.GetSingle(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + scoreThreshold = property.Value.GetSingle(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(ranker, scoreThreshold, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(ranker, scoreThreshold, serializedAdditionalRawData); + } - InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.cs index 84c5989a..24375f79 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject { - internal partial class InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(float scoreThreshold) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(float scoreThreshold) - { - ScoreThreshold = scoreThreshold; - } - - internal InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker ranker, float scoreThreshold, IDictionary serializedAdditionalRawData) - { - Ranker = ranker; - ScoreThreshold = scoreThreshold; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject() - { - } - - public InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker Ranker { get; } = InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker.Default20240821; - - public float ScoreThreshold { get; } + ScoreThreshold = scoreThreshold; } -} + + internal InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker ranker, float scoreThreshold, IDictionary serializedAdditionalRawData) + { + Ranker = ranker; + ScoreThreshold = scoreThreshold; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal InternalRunStepDetailsToolCallsFileSearchRankingOptionsObject() + { + } + + public InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker Ranker { get; } = InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker.Default20240821; + + public float ScoreThreshold { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker.cs index 3e0d585c..50126d9d 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker : IEquatable { - internal readonly partial struct InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string Default20240821Value = "default_2024_08_21"; + private const string Default20240821Value = "default_2024_08_21"; - public static InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker Default20240821 { get; } = new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(Default20240821Value); - public static bool operator ==(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker left, InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker right) => left.Equals(right); - public static bool operator !=(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker left, InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker right) => !left.Equals(right); - public static implicit operator InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(string value) => new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(value); + public static InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker Default20240821 { get; } = new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(Default20240821Value); + public static bool operator ==(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker left, InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker right) => left.Equals(right); + public static bool operator !=(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker left, InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker right) => !left.Equals(right); + public static implicit operator InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(string value) => new InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker other && Equals(other); - public bool Equals(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker other && Equals(other); + public bool Equals(InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.Serialization.cs index 92b13851..6857552a 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.Serialization.cs @@ -8,141 +8,140 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFileSearchResultObjectContent : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsFileSearchResultObjectContent : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true && Optional.IsDefined(Type)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.Value.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true && Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsToolCallsFileSearchResultObjectContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsFileSearchResultObjectContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsToolCallsFileSearchResultObjectContent DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalRunStepDetailsToolCallsFileSearchResultObjectContentType? type = default; - string text = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalRunStepDetailsToolCallsFileSearchResultObjectContent DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalRunStepDetailsToolCallsFileSearchResultObjectContentType? type = default; + string text = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - if (property.NameEquals("type"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - type = new InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(property.Value.GetString()); - continue; - } - if (property.NameEquals("text"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - text = property.Value.GetString(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = new InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsFileSearchResultObjectContent(type, text, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("text"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support writing '{options.Format}' format."); + text = property.Value.GetString(); + continue; } - } - - InternalRunStepDetailsToolCallsFileSearchResultObjectContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsFileSearchResultObjectContent(type, text, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDetailsToolCallsFileSearchResultObjectContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalRunStepDetailsToolCallsFileSearchResultObjectContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFileSearchResultObjectContent)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDetailsToolCallsFileSearchResultObjectContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.cs index 4c93e496..9fc23819 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContent.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFileSearchResultObjectContent { - internal partial class InternalRunStepDetailsToolCallsFileSearchResultObjectContent + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDetailsToolCallsFileSearchResultObjectContent() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDetailsToolCallsFileSearchResultObjectContent() - { - } - - internal InternalRunStepDetailsToolCallsFileSearchResultObjectContent(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType? type, string text, IDictionary serializedAdditionalRawData) - { - Type = type; - Text = text; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalRunStepDetailsToolCallsFileSearchResultObjectContentType? Type { get; } - public string Text { get; } + internal InternalRunStepDetailsToolCallsFileSearchResultObjectContent(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType? type, string text, IDictionary serializedAdditionalRawData) + { + Type = type; + Text = text; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalRunStepDetailsToolCallsFileSearchResultObjectContentType? Type { get; } + public string Text { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContentType.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContentType.cs index a59978a3..cacd4125 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContentType.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFileSearchResultObjectContentType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalRunStepDetailsToolCallsFileSearchResultObjectContentType : IEquatable { - internal readonly partial struct InternalRunStepDetailsToolCallsFileSearchResultObjectContentType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string TextValue = "text"; + private const string TextValue = "text"; - public static InternalRunStepDetailsToolCallsFileSearchResultObjectContentType Text { get; } = new InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(TextValue); - public static bool operator ==(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType left, InternalRunStepDetailsToolCallsFileSearchResultObjectContentType right) => left.Equals(right); - public static bool operator !=(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType left, InternalRunStepDetailsToolCallsFileSearchResultObjectContentType right) => !left.Equals(right); - public static implicit operator InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(string value) => new InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(value); + public static InternalRunStepDetailsToolCallsFileSearchResultObjectContentType Text { get; } = new InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(TextValue); + public static bool operator ==(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType left, InternalRunStepDetailsToolCallsFileSearchResultObjectContentType right) => left.Equals(right); + public static bool operator !=(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType left, InternalRunStepDetailsToolCallsFileSearchResultObjectContentType right) => !left.Equals(right); + public static implicit operator InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(string value) => new InternalRunStepDetailsToolCallsFileSearchResultObjectContentType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRunStepDetailsToolCallsFileSearchResultObjectContentType other && Equals(other); - public bool Equals(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRunStepDetailsToolCallsFileSearchResultObjectContentType other && Equals(other); + public bool Equals(InternalRunStepDetailsToolCallsFileSearchResultObjectContentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.Serialization.cs index d72f701a..2df5a353 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.Serialization.cs @@ -8,160 +8,159 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFunctionObjectFunction : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsFunctionObjectFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (SerializedAdditionalRawData?.ContainsKey("output") != true) + { + if (Output != null) { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); } - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) + else { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); + writer.WriteNull("output"); } - if (SerializedAdditionalRawData?.ContainsKey("output") != true) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Output != null) - { - writer.WritePropertyName("output"u8); - writer.WriteStringValue(Output); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("output"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsToolCallsFunctionObjectFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsFunctionObjectFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsToolCallsFunctionObjectFunction DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); + } + + internal static InternalRunStepDetailsToolCallsFunctionObjectFunction DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - string arguments = default; - string output = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("arguments"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (property.NameEquals("output"u8)) + arguments = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - output = null; - continue; - } - output = property.Value.GetString(); + output = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + output = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsFunctionObjectFunction(name, arguments, output, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsFunctionObjectFunction(name, arguments, output, serializedAdditionalRawData); + } - InternalRunStepDetailsToolCallsFunctionObjectFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunStepDetailsToolCallsFunctionObjectFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunStepDetailsToolCallsFunctionObjectFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsFunctionObjectFunction)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunStepDetailsToolCallsFunctionObjectFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.cs index 588377cd..9a086555 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsFunctionObjectFunction.cs @@ -5,35 +5,34 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsFunctionObjectFunction { - internal partial class InternalRunStepDetailsToolCallsFunctionObjectFunction + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunStepDetailsToolCallsFunctionObjectFunction(string name, string arguments, string output) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + Name = name; + Arguments = arguments; + Output = output; + } + + internal InternalRunStepDetailsToolCallsFunctionObjectFunction(string name, string arguments, string output, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunStepDetailsToolCallsFunctionObjectFunction(string name, string arguments, string output) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(arguments, nameof(arguments)); - - Name = name; - Arguments = arguments; - Output = output; - } - - internal InternalRunStepDetailsToolCallsFunctionObjectFunction(string name, string arguments, string output, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - Output = output; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalRunStepDetailsToolCallsFunctionObjectFunction() - { - } - - public string Name { get; } - public string Arguments { get; } - public string Output { get; } + Name = name; + Arguments = arguments; + Output = output; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalRunStepDetailsToolCallsFunctionObjectFunction() + { + } + + public string Name { get; } + public string Arguments { get; } + public string Output { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsObject.Serialization.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsObject.Serialization.cs index 122837da..3897c779 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsObject.Serialization.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsObject.Serialization.cs @@ -8,147 +8,146 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsObject : IJsonModel { - internal partial class InternalRunStepDetailsToolCallsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true) - { - writer.WritePropertyName("tool_calls"u8); - writer.WriteStartArray(); - foreach (var item in InternalToolCalls) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("tool_calls") != true) + { + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in InternalToolCalls) { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepDetailsToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepDetailsToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDetailsToolCallsObject(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support reading '{format}' format."); } - internal static InternalRunStepDetailsToolCallsObject DeserializeInternalRunStepDetailsToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDetailsToolCallsObject(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList toolCalls = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalRunStepDetailsToolCallsObject DeserializeInternalRunStepDetailsToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_calls"u8)) { - if (property.NameEquals("tool_calls"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(RunStepToolCall.DeserializeRunStepToolCall(item, options)); - } - toolCalls = array; - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(RunStepToolCall.DeserializeRunStepToolCall(item, options)); } + toolCalls = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepDetailsToolCallsObject(type, serializedAdditionalRawData, toolCalls); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepDetailsToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDetailsToolCallsObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepDetailsToolCallsObject(type, serializedAdditionalRawData, toolCalls); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepDetailsToolCallsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepDetailsToolCallsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support writing '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() + InternalRunStepDetailsToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDetailsToolCallsObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDetailsToolCallsObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepDetailsToolCallsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepDetailsToolCallsObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepDetailsToolCallsObject.cs b/src/Generated/Models/InternalRunStepDetailsToolCallsObject.cs index 5b428be1..db67aea7 100644 --- a/src/Generated/Models/InternalRunStepDetailsToolCallsObject.cs +++ b/src/Generated/Models/InternalRunStepDetailsToolCallsObject.cs @@ -6,25 +6,24 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepDetailsToolCallsObject : RunStepDetails { - internal partial class InternalRunStepDetailsToolCallsObject : RunStepDetails + internal InternalRunStepDetailsToolCallsObject(IEnumerable internalToolCalls) { - internal InternalRunStepDetailsToolCallsObject(IEnumerable internalToolCalls) - { - Argument.AssertNotNull(internalToolCalls, nameof(internalToolCalls)); + Argument.AssertNotNull(internalToolCalls, nameof(internalToolCalls)); - Type = "tool_calls"; - InternalToolCalls = internalToolCalls.ToList(); - } + Type = "tool_calls"; + InternalToolCalls = internalToolCalls.ToList(); + } - internal InternalRunStepDetailsToolCallsObject(string type, IDictionary serializedAdditionalRawData, IReadOnlyList internalToolCalls) : base(type, serializedAdditionalRawData) - { - InternalToolCalls = internalToolCalls; - } + internal InternalRunStepDetailsToolCallsObject(string type, IDictionary serializedAdditionalRawData, IReadOnlyList internalToolCalls) : base(type, serializedAdditionalRawData) + { + InternalToolCalls = internalToolCalls; + } - internal InternalRunStepDetailsToolCallsObject() - { - } + internal InternalRunStepDetailsToolCallsObject() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.Serialization.cs b/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.Serialization.cs index ab0da878..3783ee49 100644 --- a/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.Serialization.cs +++ b/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepFileSearchToolCallDetails : IJsonModel { - internal partial class InternalRunStepFileSearchToolCallDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepFileSearchToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepFileSearchToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepFileSearchToolCallDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support reading '{format}' format."); } - internal static InternalRunStepFileSearchToolCallDetails DeserializeInternalRunStepFileSearchToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepFileSearchToolCallDetails(document.RootElement, options); + } + + internal static InternalRunStepFileSearchToolCallDetails DeserializeInternalRunStepFileSearchToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("file_search"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_search"u8)) - { - fileSearch = InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = InternalRunStepDetailsToolCallsFileSearchObjectFileSearch.DeserializeInternalRunStepDetailsToolCallsFileSearchObjectFileSearch(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepFileSearchToolCallDetails(type, serializedAdditionalRawData, id, fileSearch); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepFileSearchToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepFileSearchToolCallDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepFileSearchToolCallDetails(type, serializedAdditionalRawData, id, fileSearch); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepFileSearchToolCallDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepFileSearchToolCallDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepFileSearchToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepFileSearchToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepFileSearchToolCallDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepFileSearchToolCallDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepFileSearchToolCallDetails(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.cs b/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.cs index af796016..1a65ed2a 100644 --- a/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.cs +++ b/src/Generated/Models/InternalRunStepFileSearchToolCallDetails.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepFileSearchToolCallDetails : RunStepToolCall { - internal partial class InternalRunStepFileSearchToolCallDetails : RunStepToolCall + internal InternalRunStepFileSearchToolCallDetails(string id, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(fileSearch, nameof(fileSearch)); + + Type = "file_search"; + Id = id; + FileSearch = fileSearch; + } + + internal InternalRunStepFileSearchToolCallDetails(string type, IDictionary serializedAdditionalRawData, string id, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(type, serializedAdditionalRawData) { - internal InternalRunStepFileSearchToolCallDetails(string id, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(fileSearch, nameof(fileSearch)); - - Type = "file_search"; - Id = id; - FileSearch = fileSearch; - } - - internal InternalRunStepFileSearchToolCallDetails(string type, IDictionary serializedAdditionalRawData, string id, InternalRunStepDetailsToolCallsFileSearchObjectFileSearch fileSearch) : base(type, serializedAdditionalRawData) - { - Id = id; - FileSearch = fileSearch; - } - - internal InternalRunStepFileSearchToolCallDetails() - { - } - - public string Id { get; } - public InternalRunStepDetailsToolCallsFileSearchObjectFileSearch FileSearch { get; } + Id = id; + FileSearch = fileSearch; } -} + + internal InternalRunStepFileSearchToolCallDetails() + { + } + + public string Id { get; } + public InternalRunStepDetailsToolCallsFileSearchObjectFileSearch FileSearch { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepFunctionToolCallDetails.Serialization.cs b/src/Generated/Models/InternalRunStepFunctionToolCallDetails.Serialization.cs index 263ace27..03eeed93 100644 --- a/src/Generated/Models/InternalRunStepFunctionToolCallDetails.Serialization.cs +++ b/src/Generated/Models/InternalRunStepFunctionToolCallDetails.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepFunctionToolCallDetails : IJsonModel { - internal partial class InternalRunStepFunctionToolCallDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("function") != true) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(_internalFunction, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("function") != true) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(_internalFunction, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunStepFunctionToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunStepFunctionToolCallDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support reading '{format}' format."); } - internal static InternalRunStepFunctionToolCallDetails DeserializeInternalRunStepFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); + } + + internal static InternalRunStepFunctionToolCallDetails DeserializeInternalRunStepFunctionToolCallDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalRunStepDetailsToolCallsFunctionObjectFunction function = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalRunStepDetailsToolCallsFunctionObjectFunction function = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("function"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("function"u8)) - { - function = InternalRunStepDetailsToolCallsFunctionObjectFunction.DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + function = InternalRunStepDetailsToolCallsFunctionObjectFunction.DeserializeInternalRunStepDetailsToolCallsFunctionObjectFunction(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunStepFunctionToolCallDetails(type, serializedAdditionalRawData, id, function); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - InternalRunStepFunctionToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunStepFunctionToolCallDetails(type, serializedAdditionalRawData, id, function); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalRunStepFunctionToolCallDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepFunctionToolCallDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepFunctionToolCallDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalRunStepFunctionToolCallDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunStepFunctionToolCallDetails(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepFunctionToolCallDetails.cs b/src/Generated/Models/InternalRunStepFunctionToolCallDetails.cs index ad318c7d..d399af4d 100644 --- a/src/Generated/Models/InternalRunStepFunctionToolCallDetails.cs +++ b/src/Generated/Models/InternalRunStepFunctionToolCallDetails.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunStepFunctionToolCallDetails : RunStepToolCall { - internal partial class InternalRunStepFunctionToolCallDetails : RunStepToolCall + internal InternalRunStepFunctionToolCallDetails(string id, InternalRunStepDetailsToolCallsFunctionObjectFunction internalFunction) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(internalFunction, nameof(internalFunction)); + + Type = "function"; + Id = id; + _internalFunction = internalFunction; + } + + internal InternalRunStepFunctionToolCallDetails(string type, IDictionary serializedAdditionalRawData, string id, InternalRunStepDetailsToolCallsFunctionObjectFunction internalFunction) : base(type, serializedAdditionalRawData) { - internal InternalRunStepFunctionToolCallDetails(string id, InternalRunStepDetailsToolCallsFunctionObjectFunction internalFunction) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(internalFunction, nameof(internalFunction)); - - Type = "function"; - Id = id; - _internalFunction = internalFunction; - } - - internal InternalRunStepFunctionToolCallDetails(string type, IDictionary serializedAdditionalRawData, string id, InternalRunStepDetailsToolCallsFunctionObjectFunction internalFunction) : base(type, serializedAdditionalRawData) - { - Id = id; - _internalFunction = internalFunction; - } - - internal InternalRunStepFunctionToolCallDetails() - { - } - - public string Id { get; } + Id = id; + _internalFunction = internalFunction; } -} + + internal InternalRunStepFunctionToolCallDetails() + { + } + + public string Id { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunStepObjectObject.cs b/src/Generated/Models/InternalRunStepObjectObject.cs index c587668a..e7a32ec7 100644 --- a/src/Generated/Models/InternalRunStepObjectObject.cs +++ b/src/Generated/Models/InternalRunStepObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalRunStepObjectObject : IEquatable { - internal readonly partial struct InternalRunStepObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalRunStepObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalRunStepObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadRunStepValue = "thread.run.step"; + private const string ThreadRunStepValue = "thread.run.step"; - public static InternalRunStepObjectObject ThreadRunStep { get; } = new InternalRunStepObjectObject(ThreadRunStepValue); - public static bool operator ==(InternalRunStepObjectObject left, InternalRunStepObjectObject right) => left.Equals(right); - public static bool operator !=(InternalRunStepObjectObject left, InternalRunStepObjectObject right) => !left.Equals(right); - public static implicit operator InternalRunStepObjectObject(string value) => new InternalRunStepObjectObject(value); + public static InternalRunStepObjectObject ThreadRunStep { get; } = new InternalRunStepObjectObject(ThreadRunStepValue); + public static bool operator ==(InternalRunStepObjectObject left, InternalRunStepObjectObject right) => left.Equals(right); + public static bool operator !=(InternalRunStepObjectObject left, InternalRunStepObjectObject right) => !left.Equals(right); + public static implicit operator InternalRunStepObjectObject(string value) => new InternalRunStepObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRunStepObjectObject other && Equals(other); - public bool Equals(InternalRunStepObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRunStepObjectObject other && Equals(other); + public bool Equals(InternalRunStepObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunToolCallObjectFunction.Serialization.cs b/src/Generated/Models/InternalRunToolCallObjectFunction.Serialization.cs index 820fb48c..1816a342 100644 --- a/src/Generated/Models/InternalRunToolCallObjectFunction.Serialization.cs +++ b/src/Generated/Models/InternalRunToolCallObjectFunction.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunToolCallObjectFunction : IJsonModel { - internal partial class InternalRunToolCallObjectFunction : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(Arguments); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalRunToolCallObjectFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalRunToolCallObjectFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunToolCallObjectFunction(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support reading '{format}' format."); } - internal static InternalRunToolCallObjectFunction DeserializeInternalRunToolCallObjectFunction(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunToolCallObjectFunction(document.RootElement, options); + } + + internal static InternalRunToolCallObjectFunction DeserializeInternalRunToolCallObjectFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - string arguments = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("arguments"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + arguments = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalRunToolCallObjectFunction(name, arguments, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalRunToolCallObjectFunction(name, arguments, serializedAdditionalRawData); + } - InternalRunToolCallObjectFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunToolCallObjectFunction(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalRunToolCallObjectFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalRunToolCallObjectFunction FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalRunToolCallObjectFunction(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunToolCallObjectFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunToolCallObjectFunction)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalRunToolCallObjectFunction FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalRunToolCallObjectFunction(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunToolCallObjectFunction.cs b/src/Generated/Models/InternalRunToolCallObjectFunction.cs index a9f72778..96e641e2 100644 --- a/src/Generated/Models/InternalRunToolCallObjectFunction.cs +++ b/src/Generated/Models/InternalRunToolCallObjectFunction.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalRunToolCallObjectFunction { - internal partial class InternalRunToolCallObjectFunction + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalRunToolCallObjectFunction(string name, string arguments) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + Name = name; + Arguments = arguments; + } + + internal InternalRunToolCallObjectFunction(string name, string arguments, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalRunToolCallObjectFunction(string name, string arguments) - { - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(arguments, nameof(arguments)); - - Name = name; - Arguments = arguments; - } - - internal InternalRunToolCallObjectFunction(string name, string arguments, IDictionary serializedAdditionalRawData) - { - Name = name; - Arguments = arguments; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalRunToolCallObjectFunction() - { - } - - public string Name { get; } - public string Arguments { get; } + Name = name; + Arguments = arguments; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalRunToolCallObjectFunction() + { + } + + public string Name { get; } + public string Arguments { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalRunToolCallObjectType.cs b/src/Generated/Models/InternalRunToolCallObjectType.cs index 55e7b1d4..fd523248 100644 --- a/src/Generated/Models/InternalRunToolCallObjectType.cs +++ b/src/Generated/Models/InternalRunToolCallObjectType.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalRunToolCallObjectType : IEquatable { - internal readonly partial struct InternalRunToolCallObjectType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalRunToolCallObjectType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalRunToolCallObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string FunctionValue = "function"; + private const string FunctionValue = "function"; - public static InternalRunToolCallObjectType Function { get; } = new InternalRunToolCallObjectType(FunctionValue); - public static bool operator ==(InternalRunToolCallObjectType left, InternalRunToolCallObjectType right) => left.Equals(right); - public static bool operator !=(InternalRunToolCallObjectType left, InternalRunToolCallObjectType right) => !left.Equals(right); - public static implicit operator InternalRunToolCallObjectType(string value) => new InternalRunToolCallObjectType(value); + public static InternalRunToolCallObjectType Function { get; } = new InternalRunToolCallObjectType(FunctionValue); + public static bool operator ==(InternalRunToolCallObjectType left, InternalRunToolCallObjectType right) => left.Equals(right); + public static bool operator !=(InternalRunToolCallObjectType left, InternalRunToolCallObjectType right) => !left.Equals(right); + public static implicit operator InternalRunToolCallObjectType(string value) => new InternalRunToolCallObjectType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalRunToolCallObjectType other && Equals(other); - public bool Equals(InternalRunToolCallObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalRunToolCallObjectType other && Equals(other); + public bool Equals(InternalRunToolCallObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalStaticChunkingStrategyDetails.Serialization.cs b/src/Generated/Models/InternalStaticChunkingStrategyDetails.Serialization.cs index f40eef60..1fbb20b3 100644 --- a/src/Generated/Models/InternalStaticChunkingStrategyDetails.Serialization.cs +++ b/src/Generated/Models/InternalStaticChunkingStrategyDetails.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalStaticChunkingStrategyDetails : IJsonModel { - internal partial class InternalStaticChunkingStrategyDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("max_chunk_size_tokens") != true) - { - writer.WritePropertyName("max_chunk_size_tokens"u8); - writer.WriteNumberValue(MaxChunkSizeTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("chunk_overlap_tokens") != true) - { - writer.WritePropertyName("chunk_overlap_tokens"u8); - writer.WriteNumberValue(ChunkOverlapTokens); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("max_chunk_size_tokens") != true) + { + writer.WritePropertyName("max_chunk_size_tokens"u8); + writer.WriteNumberValue(MaxChunkSizeTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("chunk_overlap_tokens") != true) + { + writer.WritePropertyName("chunk_overlap_tokens"u8); + writer.WriteNumberValue(ChunkOverlapTokens); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalStaticChunkingStrategyDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalStaticChunkingStrategyDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support reading '{format}' format."); } - internal static InternalStaticChunkingStrategyDetails DeserializeInternalStaticChunkingStrategyDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement, options); + } + + internal static InternalStaticChunkingStrategyDetails DeserializeInternalStaticChunkingStrategyDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int maxChunkSizeTokens = default; + int chunkOverlapTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_chunk_size_tokens"u8)) { - return null; + maxChunkSizeTokens = property.Value.GetInt32(); + continue; } - int maxChunkSizeTokens = default; - int chunkOverlapTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("chunk_overlap_tokens"u8)) { - if (property.NameEquals("max_chunk_size_tokens"u8)) - { - maxChunkSizeTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("chunk_overlap_tokens"u8)) - { - chunkOverlapTokens = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + chunkOverlapTokens = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalStaticChunkingStrategyDetails(maxChunkSizeTokens, chunkOverlapTokens, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalStaticChunkingStrategyDetails(maxChunkSizeTokens, chunkOverlapTokens, serializedAdditionalRawData); + } - InternalStaticChunkingStrategyDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalStaticChunkingStrategyDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalStaticChunkingStrategyDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyDetails)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalStaticChunkingStrategyDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalStaticChunkingStrategyDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalStaticChunkingStrategyDetails.cs b/src/Generated/Models/InternalStaticChunkingStrategyDetails.cs index 26a6aa2e..1b21b52e 100644 --- a/src/Generated/Models/InternalStaticChunkingStrategyDetails.cs +++ b/src/Generated/Models/InternalStaticChunkingStrategyDetails.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalStaticChunkingStrategyDetails { - internal partial class InternalStaticChunkingStrategyDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalStaticChunkingStrategyDetails(int maxChunkSizeTokens, int chunkOverlapTokens) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalStaticChunkingStrategyDetails(int maxChunkSizeTokens, int chunkOverlapTokens) - { - MaxChunkSizeTokens = maxChunkSizeTokens; - ChunkOverlapTokens = chunkOverlapTokens; - } - - internal InternalStaticChunkingStrategyDetails(int maxChunkSizeTokens, int chunkOverlapTokens, IDictionary serializedAdditionalRawData) - { - MaxChunkSizeTokens = maxChunkSizeTokens; - ChunkOverlapTokens = chunkOverlapTokens; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + } - internal InternalStaticChunkingStrategyDetails() - { - } + internal InternalStaticChunkingStrategyDetails(int maxChunkSizeTokens, int chunkOverlapTokens, IDictionary serializedAdditionalRawData) + { + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int MaxChunkSizeTokens { get; set; } - public int ChunkOverlapTokens { get; set; } + internal InternalStaticChunkingStrategyDetails() + { } -} + + public int MaxChunkSizeTokens { get; set; } + public int ChunkOverlapTokens { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.Serialization.cs b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.Serialization.cs index 47c705b9..10e0d62c 100644 --- a/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.Serialization.cs +++ b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalStaticChunkingStrategyRequestParam : IJsonModel { - internal partial class InternalStaticChunkingStrategyRequestParam : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("static") != true) - { - writer.WritePropertyName("static"u8); - writer.WriteObjectValue(Static, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("static") != true) + { + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(Static, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalStaticChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalStaticChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support reading '{format}' format."); } - internal static InternalStaticChunkingStrategyRequestParam DeserializeInternalStaticChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement, options); + } + + internal static InternalStaticChunkingStrategyRequestParam DeserializeInternalStaticChunkingStrategyRequestParam(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalStaticChunkingStrategyDetails @static = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) { - return null; + @static = InternalStaticChunkingStrategyDetails.DeserializeInternalStaticChunkingStrategyDetails(property.Value, options); + continue; } - InternalStaticChunkingStrategyDetails @static = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("static"u8)) - { - @static = InternalStaticChunkingStrategyDetails.DeserializeInternalStaticChunkingStrategyDetails(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalStaticChunkingStrategyRequestParam(type, serializedAdditionalRawData, @static); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalStaticChunkingStrategyRequestParam(type, serializedAdditionalRawData, @static); + } - InternalStaticChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalStaticChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalStaticChunkingStrategyRequestParam FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalStaticChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalStaticChunkingStrategyRequestParam FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalStaticChunkingStrategyRequestParam(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.cs b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.cs index 2b96bd6e..e2c056c3 100644 --- a/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.cs +++ b/src/Generated/Models/InternalStaticChunkingStrategyRequestParam.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalStaticChunkingStrategyRequestParam : InternalFileChunkingStrategyRequestParam { - internal partial class InternalStaticChunkingStrategyRequestParam : InternalFileChunkingStrategyRequestParam + public InternalStaticChunkingStrategyRequestParam(InternalStaticChunkingStrategyDetails @static) { - public InternalStaticChunkingStrategyRequestParam(InternalStaticChunkingStrategyDetails @static) - { - Argument.AssertNotNull(@static, nameof(@static)); - - Type = "static"; - Static = @static; - } + Argument.AssertNotNull(@static, nameof(@static)); - internal InternalStaticChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData, InternalStaticChunkingStrategyDetails @static) : base(type, serializedAdditionalRawData) - { - Static = @static; - } + Type = "static"; + Static = @static; + } - internal InternalStaticChunkingStrategyRequestParam() - { - } + internal InternalStaticChunkingStrategyRequestParam(string type, IDictionary serializedAdditionalRawData, InternalStaticChunkingStrategyDetails @static) : base(type, serializedAdditionalRawData) + { + Static = @static; + } - public InternalStaticChunkingStrategyDetails Static { get; } + internal InternalStaticChunkingStrategyRequestParam() + { } -} + + public InternalStaticChunkingStrategyDetails Static { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalSubmitToolOutputsRunRequest.Serialization.cs b/src/Generated/Models/InternalSubmitToolOutputsRunRequest.Serialization.cs index d6c8b0d3..d1606a2d 100644 --- a/src/Generated/Models/InternalSubmitToolOutputsRunRequest.Serialization.cs +++ b/src/Generated/Models/InternalSubmitToolOutputsRunRequest.Serialization.cs @@ -8,159 +8,158 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalSubmitToolOutputsRunRequest : IJsonModel { - internal partial class InternalSubmitToolOutputsRunRequest : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("tool_outputs") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("tool_outputs"u8); + writer.WriteStartArray(); + foreach (var item in ToolOutputs) { - throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support writing '{format}' format."); + writer.WriteObjectValue(item, options); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("tool_outputs") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + { + if (Stream != null) { - writer.WritePropertyName("tool_outputs"u8); - writer.WriteStartArray(); - foreach (var item in ToolOutputs) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); } - if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + else { - if (Stream != null) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - else - { - writer.WriteNull("stream"); - } + writer.WriteNull("stream"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalSubmitToolOutputsRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalSubmitToolOutputsRunRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalSubmitToolOutputsRunRequest(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support reading '{format}' format."); } - internal static InternalSubmitToolOutputsRunRequest DeserializeInternalSubmitToolOutputsRunRequest(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalSubmitToolOutputsRunRequest(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList toolOutputs = default; - bool? stream = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalSubmitToolOutputsRunRequest DeserializeInternalSubmitToolOutputsRunRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolOutputs = default; + bool? stream = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_outputs"u8)) { - if (property.NameEquals("tool_outputs"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolOutput.DeserializeToolOutput(item, options)); - } - toolOutputs = array; - continue; + array.Add(ToolOutput.DeserializeToolOutput(item, options)); } - if (property.NameEquals("stream"u8)) + toolOutputs = array; + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - stream = null; - continue; - } - stream = property.Value.GetBoolean(); + stream = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + stream = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalSubmitToolOutputsRunRequest(toolOutputs, stream, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalSubmitToolOutputsRunRequest(toolOutputs, stream, serializedAdditionalRawData); + } - InternalSubmitToolOutputsRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalSubmitToolOutputsRunRequest(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalSubmitToolOutputsRunRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalSubmitToolOutputsRunRequest FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalSubmitToolOutputsRunRequest(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalSubmitToolOutputsRunRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalSubmitToolOutputsRunRequest)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalSubmitToolOutputsRunRequest FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalSubmitToolOutputsRunRequest(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalSubmitToolOutputsRunRequest.cs b/src/Generated/Models/InternalSubmitToolOutputsRunRequest.cs index 13a44291..d2eef5ff 100644 --- a/src/Generated/Models/InternalSubmitToolOutputsRunRequest.cs +++ b/src/Generated/Models/InternalSubmitToolOutputsRunRequest.cs @@ -6,30 +6,29 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalSubmitToolOutputsRunRequest { - internal partial class InternalSubmitToolOutputsRunRequest + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalSubmitToolOutputsRunRequest(IEnumerable toolOutputs) + { + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + + ToolOutputs = toolOutputs.ToList(); + } + + internal InternalSubmitToolOutputsRunRequest(IList toolOutputs, bool? stream, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalSubmitToolOutputsRunRequest(IEnumerable toolOutputs) - { - Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); - - ToolOutputs = toolOutputs.ToList(); - } - - internal InternalSubmitToolOutputsRunRequest(IList toolOutputs, bool? stream, IDictionary serializedAdditionalRawData) - { - ToolOutputs = toolOutputs; - Stream = stream; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalSubmitToolOutputsRunRequest() - { - } - - public IList ToolOutputs { get; } - public bool? Stream { get; set; } + ToolOutputs = toolOutputs; + Stream = stream; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalSubmitToolOutputsRunRequest() + { + } + + public IList ToolOutputs { get; } + public bool? Stream { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalThreadObjectObject.cs b/src/Generated/Models/InternalThreadObjectObject.cs index 1ae26848..a11d0361 100644 --- a/src/Generated/Models/InternalThreadObjectObject.cs +++ b/src/Generated/Models/InternalThreadObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalThreadObjectObject : IEquatable { - internal readonly partial struct InternalThreadObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalThreadObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalThreadObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ThreadValue = "thread"; + private const string ThreadValue = "thread"; - public static InternalThreadObjectObject Thread { get; } = new InternalThreadObjectObject(ThreadValue); - public static bool operator ==(InternalThreadObjectObject left, InternalThreadObjectObject right) => left.Equals(right); - public static bool operator !=(InternalThreadObjectObject left, InternalThreadObjectObject right) => !left.Equals(right); - public static implicit operator InternalThreadObjectObject(string value) => new InternalThreadObjectObject(value); + public static InternalThreadObjectObject Thread { get; } = new InternalThreadObjectObject(ThreadValue); + public static bool operator ==(InternalThreadObjectObject left, InternalThreadObjectObject right) => left.Equals(right); + public static bool operator !=(InternalThreadObjectObject left, InternalThreadObjectObject right) => !left.Equals(right); + public static implicit operator InternalThreadObjectObject(string value) => new InternalThreadObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalThreadObjectObject other && Equals(other); - public bool Equals(InternalThreadObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalThreadObjectObject other && Equals(other); + public bool Equals(InternalThreadObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalThreadObjectToolResources.Serialization.cs b/src/Generated/Models/InternalThreadObjectToolResources.Serialization.cs index d33c9da5..1b3848b5 100644 --- a/src/Generated/Models/InternalThreadObjectToolResources.Serialization.cs +++ b/src/Generated/Models/InternalThreadObjectToolResources.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalThreadObjectToolResources : IJsonModel { - internal partial class InternalThreadObjectToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - writer.WriteObjectValue(FileSearch, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalThreadObjectToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalThreadObjectToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalThreadObjectToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support reading '{format}' format."); } - internal static InternalThreadObjectToolResources DeserializeInternalThreadObjectToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalThreadObjectToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalThreadObjectToolResourcesCodeInterpreter codeInterpreter = default; - InternalThreadObjectToolResourcesFileSearch fileSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalThreadObjectToolResources DeserializeInternalThreadObjectToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalThreadObjectToolResourcesCodeInterpreter codeInterpreter = default; + InternalThreadObjectToolResourcesFileSearch fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("code_interpreter"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = InternalThreadObjectToolResourcesCodeInterpreter.DeserializeInternalThreadObjectToolResourcesCodeInterpreter(property.Value, options); continue; } - if (property.NameEquals("file_search"u8)) + codeInterpreter = InternalThreadObjectToolResourcesCodeInterpreter.DeserializeInternalThreadObjectToolResourcesCodeInterpreter(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = InternalThreadObjectToolResourcesFileSearch.DeserializeInternalThreadObjectToolResourcesFileSearch(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = InternalThreadObjectToolResourcesFileSearch.DeserializeInternalThreadObjectToolResourcesFileSearch(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalThreadObjectToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalThreadObjectToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); + } - InternalThreadObjectToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalThreadObjectToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalThreadObjectToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalThreadObjectToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalThreadObjectToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalThreadObjectToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalThreadObjectToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalThreadObjectToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalThreadObjectToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalThreadObjectToolResources.cs b/src/Generated/Models/InternalThreadObjectToolResources.cs index 5d766bb6..e4950f18 100644 --- a/src/Generated/Models/InternalThreadObjectToolResources.cs +++ b/src/Generated/Models/InternalThreadObjectToolResources.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalThreadObjectToolResources { - internal partial class InternalThreadObjectToolResources + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalThreadObjectToolResources() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalThreadObjectToolResources() - { - } - - internal InternalThreadObjectToolResources(InternalThreadObjectToolResourcesCodeInterpreter codeInterpreter, InternalThreadObjectToolResourcesFileSearch fileSearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public InternalThreadObjectToolResourcesCodeInterpreter CodeInterpreter { get; } - public InternalThreadObjectToolResourcesFileSearch FileSearch { get; } + internal InternalThreadObjectToolResources(InternalThreadObjectToolResourcesCodeInterpreter codeInterpreter, InternalThreadObjectToolResourcesFileSearch fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public InternalThreadObjectToolResourcesCodeInterpreter CodeInterpreter { get; } + public InternalThreadObjectToolResourcesFileSearch FileSearch { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.Serialization.cs b/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.Serialization.cs index a65e1920..86c9d425 100644 --- a/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.Serialization.cs +++ b/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalThreadObjectToolResourcesCodeInterpreter : IJsonModel { - internal partial class InternalThreadObjectToolResourcesCodeInterpreter : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalThreadObjectToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalThreadObjectToolResourcesCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalThreadObjectToolResourcesCodeInterpreter(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support reading '{format}' format."); } - internal static InternalThreadObjectToolResourcesCodeInterpreter DeserializeInternalThreadObjectToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalThreadObjectToolResourcesCodeInterpreter(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList fileIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalThreadObjectToolResourcesCodeInterpreter DeserializeInternalThreadObjectToolResourcesCodeInterpreter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + fileIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalThreadObjectToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalThreadObjectToolResourcesCodeInterpreter(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalThreadObjectToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalThreadObjectToolResourcesCodeInterpreter(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalThreadObjectToolResourcesCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalThreadObjectToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalThreadObjectToolResourcesCodeInterpreter(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalThreadObjectToolResourcesCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesCodeInterpreter)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalThreadObjectToolResourcesCodeInterpreter FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalThreadObjectToolResourcesCodeInterpreter(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.cs b/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.cs index ddcfa61e..27df8a0b 100644 --- a/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.cs +++ b/src/Generated/Models/InternalThreadObjectToolResourcesCodeInterpreter.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalThreadObjectToolResourcesCodeInterpreter { - internal partial class InternalThreadObjectToolResourcesCodeInterpreter + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalThreadObjectToolResourcesCodeInterpreter() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalThreadObjectToolResourcesCodeInterpreter() - { - FileIds = new ChangeTrackingList(); - } - - internal InternalThreadObjectToolResourcesCodeInterpreter(IReadOnlyList fileIds, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + } - public IReadOnlyList FileIds { get; } + internal InternalThreadObjectToolResourcesCodeInterpreter(IReadOnlyList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IReadOnlyList FileIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.Serialization.cs b/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.Serialization.cs index f2697edf..06398904 100644 --- a/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.Serialization.cs +++ b/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalThreadObjectToolResourcesFileSearch : IJsonModel { - internal partial class InternalThreadObjectToolResourcesFileSearch : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("vector_store_ids") != true && Optional.IsCollectionDefined(VectorStoreIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("vector_store_ids") != true && Optional.IsCollectionDefined(VectorStoreIds)) + { + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (var item in VectorStoreIds) { - writer.WritePropertyName("vector_store_ids"u8); - writer.WriteStartArray(); - foreach (var item in VectorStoreIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalThreadObjectToolResourcesFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalThreadObjectToolResourcesFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalThreadObjectToolResourcesFileSearch(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support reading '{format}' format."); } - internal static InternalThreadObjectToolResourcesFileSearch DeserializeInternalThreadObjectToolResourcesFileSearch(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalThreadObjectToolResourcesFileSearch(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList vectorStoreIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalThreadObjectToolResourcesFileSearch DeserializeInternalThreadObjectToolResourcesFileSearch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList vectorStoreIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vector_store_ids"u8)) { - if (property.NameEquals("vector_store_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - vectorStoreIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + vectorStoreIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalThreadObjectToolResourcesFileSearch(vectorStoreIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalThreadObjectToolResourcesFileSearch(vectorStoreIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalThreadObjectToolResourcesFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalThreadObjectToolResourcesFileSearch(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalThreadObjectToolResourcesFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalThreadObjectToolResourcesFileSearch FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalThreadObjectToolResourcesFileSearch(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalThreadObjectToolResourcesFileSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalThreadObjectToolResourcesFileSearch)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalThreadObjectToolResourcesFileSearch FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalThreadObjectToolResourcesFileSearch(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.cs b/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.cs index 4214562a..6c1519db 100644 --- a/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.cs +++ b/src/Generated/Models/InternalThreadObjectToolResourcesFileSearch.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalThreadObjectToolResourcesFileSearch { - internal partial class InternalThreadObjectToolResourcesFileSearch + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalThreadObjectToolResourcesFileSearch() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalThreadObjectToolResourcesFileSearch() - { - VectorStoreIds = new ChangeTrackingList(); - } - - internal InternalThreadObjectToolResourcesFileSearch(IReadOnlyList vectorStoreIds, IDictionary serializedAdditionalRawData) - { - VectorStoreIds = vectorStoreIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + VectorStoreIds = new ChangeTrackingList(); + } - public IReadOnlyList VectorStoreIds { get; } + internal InternalThreadObjectToolResourcesFileSearch(IReadOnlyList vectorStoreIds, IDictionary serializedAdditionalRawData) + { + VectorStoreIds = vectorStoreIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IReadOnlyList VectorStoreIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.Serialization.cs b/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.Serialization.cs index 3b188f3b..15d58270 100644 --- a/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.Serialization.cs +++ b/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.Serialization.cs @@ -8,140 +8,139 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalToolResourcesFileSearchIdsOnly : IJsonModel { - internal partial class InternalToolResourcesFileSearchIdsOnly : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("vector_store_ids") != true && Optional.IsCollectionDefined(VectorStoreIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("vector_store_ids") != true && Optional.IsCollectionDefined(VectorStoreIds)) + { + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (var item in VectorStoreIds) { - writer.WritePropertyName("vector_store_ids"u8); - writer.WriteStartArray(); - foreach (var item in VectorStoreIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData != null) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalToolResourcesFileSearchIdsOnly IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalToolResourcesFileSearchIdsOnly IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalToolResourcesFileSearchIdsOnly(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support reading '{format}' format."); } - internal static InternalToolResourcesFileSearchIdsOnly DeserializeInternalToolResourcesFileSearchIdsOnly(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolResourcesFileSearchIdsOnly(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList vectorStoreIds = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static InternalToolResourcesFileSearchIdsOnly DeserializeInternalToolResourcesFileSearchIdsOnly(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList vectorStoreIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vector_store_ids"u8)) { - if (property.NameEquals("vector_store_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - vectorStoreIds = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(item.GetString()); } + vectorStoreIds = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalToolResourcesFileSearchIdsOnly(vectorStoreIds ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalToolResourcesFileSearchIdsOnly(vectorStoreIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - InternalToolResourcesFileSearchIdsOnly IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalToolResourcesFileSearchIdsOnly(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalToolResourcesFileSearchIdsOnly IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalToolResourcesFileSearchIdsOnly FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalToolResourcesFileSearchIdsOnly(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalToolResourcesFileSearchIdsOnly(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolResourcesFileSearchIdsOnly)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalToolResourcesFileSearchIdsOnly FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalToolResourcesFileSearchIdsOnly(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.cs b/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.cs index 33ed0185..c2ca0b91 100644 --- a/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.cs +++ b/src/Generated/Models/InternalToolResourcesFileSearchIdsOnly.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalToolResourcesFileSearchIdsOnly { - internal partial class InternalToolResourcesFileSearchIdsOnly + internal IDictionary SerializedAdditionalRawData { get; set; } + public InternalToolResourcesFileSearchIdsOnly() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public InternalToolResourcesFileSearchIdsOnly() - { - VectorStoreIds = new ChangeTrackingList(); - } - - internal InternalToolResourcesFileSearchIdsOnly(IList vectorStoreIds, IDictionary serializedAdditionalRawData) - { - VectorStoreIds = vectorStoreIds; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + VectorStoreIds = new ChangeTrackingList(); + } - public IList VectorStoreIds { get; } + internal InternalToolResourcesFileSearchIdsOnly(IList vectorStoreIds, IDictionary serializedAdditionalRawData) + { + VectorStoreIds = vectorStoreIds; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList VectorStoreIds { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalTruncationObjectType.cs b/src/Generated/Models/InternalTruncationObjectType.cs index a6a78832..da4dce90 100644 --- a/src/Generated/Models/InternalTruncationObjectType.cs +++ b/src/Generated/Models/InternalTruncationObjectType.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal readonly partial struct InternalTruncationObjectType : IEquatable { - internal readonly partial struct InternalTruncationObjectType : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalTruncationObjectType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalTruncationObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string AutoValue = "auto"; - private const string LastMessagesValue = "last_messages"; + private const string AutoValue = "auto"; + private const string LastMessagesValue = "last_messages"; - public static InternalTruncationObjectType Auto { get; } = new InternalTruncationObjectType(AutoValue); - public static InternalTruncationObjectType LastMessages { get; } = new InternalTruncationObjectType(LastMessagesValue); - public static bool operator ==(InternalTruncationObjectType left, InternalTruncationObjectType right) => left.Equals(right); - public static bool operator !=(InternalTruncationObjectType left, InternalTruncationObjectType right) => !left.Equals(right); - public static implicit operator InternalTruncationObjectType(string value) => new InternalTruncationObjectType(value); + public static InternalTruncationObjectType Auto { get; } = new InternalTruncationObjectType(AutoValue); + public static InternalTruncationObjectType LastMessages { get; } = new InternalTruncationObjectType(LastMessagesValue); + public static bool operator ==(InternalTruncationObjectType left, InternalTruncationObjectType right) => left.Equals(right); + public static bool operator !=(InternalTruncationObjectType left, InternalTruncationObjectType right) => !left.Equals(right); + public static implicit operator InternalTruncationObjectType(string value) => new InternalTruncationObjectType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalTruncationObjectType other && Equals(other); - public bool Equals(InternalTruncationObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalTruncationObjectType other && Equals(other); + public bool Equals(InternalTruncationObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownAssistantResponseFormat.Serialization.cs b/src/Generated/Models/InternalUnknownAssistantResponseFormat.Serialization.cs index ff9e4c05..295e2612 100644 --- a/src/Generated/Models/InternalUnknownAssistantResponseFormat.Serialization.cs +++ b/src/Generated/Models/InternalUnknownAssistantResponseFormat.Serialization.cs @@ -8,115 +8,114 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalUnknownAssistantResponseFormat : IJsonModel { - internal partial class InternalUnknownAssistantResponseFormat : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - AssistantResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AssistantResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantResponseFormat(document.RootElement, options); + throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support reading '{format}' format."); } - internal static InternalUnknownAssistantResponseFormat DeserializeInternalUnknownAssistantResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantResponseFormat(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalUnknownAssistantResponseFormat DeserializeInternalUnknownAssistantResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = property.Value.GetString(); + continue; } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (true) { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownAssistantResponseFormat(type, serializedAdditionalRawData); } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownAssistantResponseFormat(type, serializedAdditionalRawData); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support writing '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support writing '{options.Format}' format."); } + } - AssistantResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + AssistantResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistantResponseFormat(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantResponseFormat)} does not support reading '{options.Format}' format."); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownAssistantResponseFormat.cs b/src/Generated/Models/InternalUnknownAssistantResponseFormat.cs index 13ee16c7..885bbe85 100644 --- a/src/Generated/Models/InternalUnknownAssistantResponseFormat.cs +++ b/src/Generated/Models/InternalUnknownAssistantResponseFormat.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class InternalUnknownAssistantResponseFormat : AssistantResponseFormat { - internal partial class InternalUnknownAssistantResponseFormat : AssistantResponseFormat + internal InternalUnknownAssistantResponseFormat(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal InternalUnknownAssistantResponseFormat(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal InternalUnknownAssistantResponseFormat() - { - } + internal InternalUnknownAssistantResponseFormat() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs b/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs index 4ff26850..45e7fce1 100644 --- a/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs +++ b/src/Generated/Models/InternalUnknownChatMessage.Serialization.cs @@ -8,96 +8,95 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalUnknownChatMessage : IJsonModel { - internal partial class InternalUnknownChatMessage : IJsonModel + ChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{format}' format."); } - internal static InternalUnknownChatMessage DeserializeInternalUnknownChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessage(document.RootElement, options); + } + + internal static InternalUnknownChatMessage DeserializeInternalUnknownChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChatMessageRole role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("role"u8)) { - return null; + role = property.Value.GetString().ToChatMessageRole(); + continue; } - ChatMessageRole role = default; - IList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("content"u8)) { - if (property.NameEquals("role"u8)) - { - role = property.Value.GetString().ToChatMessageRole(); - continue; - } - if (property.NameEquals("content"u8)) - { - DeserializeContentValue(property, ref content); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + DeserializeContentValue(property, ref content); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatMessage)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - ChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatMessage)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalUnknownChatMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownChatMessage(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessage)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownChatMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownChatMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownChatMessage.cs b/src/Generated/Models/InternalUnknownChatMessage.cs index 8f25fa22..c0150fc9 100644 --- a/src/Generated/Models/InternalUnknownChatMessage.cs +++ b/src/Generated/Models/InternalUnknownChatMessage.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalUnknownChatMessage : ChatMessage { - internal partial class InternalUnknownChatMessage : ChatMessage + internal InternalUnknownChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData) : base(role, content, serializedAdditionalRawData) { - internal InternalUnknownChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData) : base(role, content, serializedAdditionalRawData) - { - } + } - internal InternalUnknownChatMessage() - { - } + internal InternalUnknownChatMessage() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownChatResponseFormat.Serialization.cs b/src/Generated/Models/InternalUnknownChatResponseFormat.Serialization.cs index 756d520b..c22d3703 100644 --- a/src/Generated/Models/InternalUnknownChatResponseFormat.Serialization.cs +++ b/src/Generated/Models/InternalUnknownChatResponseFormat.Serialization.cs @@ -8,90 +8,89 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalUnknownChatResponseFormat : IJsonModel { - internal partial class InternalUnknownChatResponseFormat : IJsonModel + ChatResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ChatResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatResponseFormat(document.RootElement, options); + throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{format}' format."); } - internal static InternalUnknownChatResponseFormat DeserializeInternalUnknownChatResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatResponseFormat(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownChatResponseFormat(type, serializedAdditionalRawData); - } + internal static InternalUnknownChatResponseFormat DeserializeInternalUnknownChatResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support writing '{options.Format}' format."); - } + return null; } - - ChatResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatResponseFormat(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownChatResponseFormat(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalUnknownChatResponseFormat FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownChatResponseFormat(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support writing '{options.Format}' format."); } + } + + ChatResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeChatResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatResponseFormat)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownChatResponseFormat FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownChatResponseFormat(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownChatResponseFormat.cs b/src/Generated/Models/InternalUnknownChatResponseFormat.cs index e3def713..a1529af5 100644 --- a/src/Generated/Models/InternalUnknownChatResponseFormat.cs +++ b/src/Generated/Models/InternalUnknownChatResponseFormat.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +internal partial class InternalUnknownChatResponseFormat : ChatResponseFormat { - internal partial class InternalUnknownChatResponseFormat : ChatResponseFormat + internal InternalUnknownChatResponseFormat(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal InternalUnknownChatResponseFormat(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal InternalUnknownChatResponseFormat() - { - } + internal InternalUnknownChatResponseFormat() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownChunkingStrategy.Serialization.cs b/src/Generated/Models/InternalUnknownChunkingStrategy.Serialization.cs index 6ac1d2f8..24dbf43d 100644 --- a/src/Generated/Models/InternalUnknownChunkingStrategy.Serialization.cs +++ b/src/Generated/Models/InternalUnknownChunkingStrategy.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalUnknownChunkingStrategy : IJsonModel { - internal partial class InternalUnknownChunkingStrategy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support writing '{format}' format."); } - InternalUnknownChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalUnknownChunkingStrategy(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalUnknownChunkingStrategy DeserializeInternalUnknownChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownChunkingStrategy(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalUnknownChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support reading '{format}' format."); } - InternalUnknownChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalUnknownChunkingStrategy(document.RootElement, options); + } + + internal static InternalUnknownChunkingStrategy DeserializeInternalUnknownChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalUnknownChunkingStrategy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownChunkingStrategy(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalUnknownChunkingStrategy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownChunkingStrategy(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support writing '{options.Format}' format."); } + } + + InternalUnknownChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalUnknownChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalUnknownChunkingStrategy)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownChunkingStrategy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownChunkingStrategy.cs b/src/Generated/Models/InternalUnknownChunkingStrategy.cs index d9026a4d..4def4414 100644 --- a/src/Generated/Models/InternalUnknownChunkingStrategy.cs +++ b/src/Generated/Models/InternalUnknownChunkingStrategy.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalUnknownChunkingStrategy : FileChunkingStrategy { - internal partial class InternalUnknownChunkingStrategy : FileChunkingStrategy + public InternalUnknownChunkingStrategy() { - public InternalUnknownChunkingStrategy() - { - Type = "other"; - } + Type = "other"; + } - internal InternalUnknownChunkingStrategy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + internal InternalUnknownChunkingStrategy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.Serialization.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.Serialization.cs index 5a958dfe..eb77df4b 100644 --- a/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.Serialization.cs +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalUnknownFileChunkingStrategyRequestParamProxy : IJsonModel { - internal partial class InternalUnknownFileChunkingStrategyRequestParamProxy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{format}' format."); } - InternalFileChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalUnknownFileChunkingStrategyRequestParamProxy DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownFileChunkingStrategyRequestParamProxy(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalFileChunkingStrategyRequestParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{format}' format."); } - InternalFileChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } + + internal static InternalUnknownFileChunkingStrategyRequestParamProxy DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownFileChunkingStrategyRequestParamProxy(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalUnknownFileChunkingStrategyRequestParamProxy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support writing '{options.Format}' format."); } + } + + InternalFileChunkingStrategyRequestParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFileChunkingStrategyRequestParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileChunkingStrategyRequestParam)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownFileChunkingStrategyRequestParamProxy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownFileChunkingStrategyRequestParamProxy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.cs index 91f50cab..40fa7786 100644 --- a/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.cs +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyRequestParamProxy.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalUnknownFileChunkingStrategyRequestParamProxy : InternalFileChunkingStrategyRequestParam { - internal partial class InternalUnknownFileChunkingStrategyRequestParamProxy : InternalFileChunkingStrategyRequestParam + internal InternalUnknownFileChunkingStrategyRequestParamProxy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal InternalUnknownFileChunkingStrategyRequestParamProxy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal InternalUnknownFileChunkingStrategyRequestParamProxy() - { - } + internal InternalUnknownFileChunkingStrategyRequestParamProxy() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.Serialization.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.Serialization.cs index c98a69cd..c6b8fa57 100644 --- a/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.Serialization.cs +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy : IJsonModel { - internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{format}' format."); } - FileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFileChunkingStrategy(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalUnknownFileChunkingStrategyResponseParamProxy DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownFileChunkingStrategyResponseParamProxy(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + FileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{format}' format."); } - FileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } + + internal static InternalUnknownFileChunkingStrategyResponseParamProxy DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFileChunkingStrategy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownFileChunkingStrategyResponseParamProxy(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalUnknownFileChunkingStrategyResponseParamProxy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support writing '{options.Format}' format."); } + } + + FileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileChunkingStrategy)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownFileChunkingStrategyResponseParamProxy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownFileChunkingStrategyResponseParamProxy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.cs b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.cs index db5bbec8..93edf08c 100644 --- a/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.cs +++ b/src/Generated/Models/InternalUnknownFileChunkingStrategyResponseParamProxy.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy : FileChunkingStrategy { - internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy : FileChunkingStrategy + internal InternalUnknownFileChunkingStrategyResponseParamProxy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal InternalUnknownFileChunkingStrategyResponseParamProxy(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal InternalUnknownFileChunkingStrategyResponseParamProxy() - { - } + internal InternalUnknownFileChunkingStrategyResponseParamProxy() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.Serialization.cs b/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.Serialization.cs index 43b17f90..533663dc 100644 --- a/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.Serialization.cs +++ b/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalUnknownOmniTypedResponseFormat : IJsonModel { - internal partial class InternalUnknownOmniTypedResponseFormat : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{format}' format."); } - InternalOmniTypedResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static InternalUnknownOmniTypedResponseFormat DeserializeInternalUnknownOmniTypedResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownOmniTypedResponseFormat(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalOmniTypedResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{format}' format."); } - InternalOmniTypedResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); + } + + internal static InternalUnknownOmniTypedResponseFormat DeserializeInternalUnknownOmniTypedResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUnknownOmniTypedResponseFormat(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new InternalUnknownOmniTypedResponseFormat FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownOmniTypedResponseFormat(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support writing '{options.Format}' format."); } + } + + InternalOmniTypedResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalOmniTypedResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalOmniTypedResponseFormat)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new InternalUnknownOmniTypedResponseFormat FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUnknownOmniTypedResponseFormat(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.cs b/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.cs index 8ae4808f..f19477af 100644 --- a/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.cs +++ b/src/Generated/Models/InternalUnknownOmniTypedResponseFormat.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class InternalUnknownOmniTypedResponseFormat : InternalOmniTypedResponseFormat { - internal partial class InternalUnknownOmniTypedResponseFormat : InternalOmniTypedResponseFormat + internal InternalUnknownOmniTypedResponseFormat(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal InternalUnknownOmniTypedResponseFormat(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal InternalUnknownOmniTypedResponseFormat() - { - } + internal InternalUnknownOmniTypedResponseFormat() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUpload.Serialization.cs b/src/Generated/Models/InternalUpload.Serialization.cs index 6b2b8604..104f8c5b 100644 --- a/src/Generated/Models/InternalUpload.Serialization.cs +++ b/src/Generated/Models/InternalUpload.Serialization.cs @@ -8,240 +8,239 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalUpload : IJsonModel { - internal partial class InternalUpload : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalUpload)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalUpload)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) - { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("filename") != true) - { - writer.WritePropertyName("filename"u8); - writer.WriteStringValue(Filename); - } - if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) - { - writer.WritePropertyName("bytes"u8); - writer.WriteNumberValue(Bytes); - } - if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) - { - writer.WritePropertyName("purpose"u8); - writer.WriteStringValue(Purpose); - } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) - { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("filename") != true) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + { + writer.WritePropertyName("bytes"u8); + writer.WriteNumberValue(Bytes); + } + if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) + { + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true) + { + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true && Optional.IsDefined(Object)) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.Value.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("file") != true && Optional.IsDefined(File)) + { + if (File != null) { - writer.WritePropertyName("expires_at"u8); - writer.WriteNumberValue(ExpiresAt, "U"); + writer.WritePropertyName("file"u8); + writer.WriteObjectValue(File, options); } - if (SerializedAdditionalRawData?.ContainsKey("object") != true && Optional.IsDefined(Object)) + else { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.Value.ToString()); + writer.WriteNull("file"); } - if (SerializedAdditionalRawData?.ContainsKey("file") != true && Optional.IsDefined(File)) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (File != null) - { - writer.WritePropertyName("file"u8); - writer.WriteObjectValue(File, options); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("file"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalUpload IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalUpload IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalUpload)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalUpload(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalUpload)} does not support reading '{format}' format."); } - internal static InternalUpload DeserializeInternalUpload(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalUpload(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalUpload DeserializeInternalUpload(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + DateTimeOffset createdAt = default; + string filename = default; + int bytes = default; + string purpose = default; + InternalUploadStatus status = default; + DateTimeOffset expiresAt = default; + InternalUploadObject? @object = default; + OpenAIFileInfo file = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - DateTimeOffset createdAt = default; - string filename = default; - int bytes = default; - string purpose = default; - InternalUploadStatus status = default; - DateTimeOffset expiresAt = default; - InternalUploadObject? @object = default; - OpenAIFileInfo file = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("created_at"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("filename"u8)) - { - filename = property.Value.GetString(); - continue; - } - if (property.NameEquals("bytes"u8)) - { - bytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("purpose"u8)) - { - purpose = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new InternalUploadStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("expires_at"u8)) - { - expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("object"u8)) + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("filename"u8)) + { + filename = property.Value.GetString(); + continue; + } + if (property.NameEquals("bytes"u8)) + { + bytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("purpose"u8)) + { + purpose = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new InternalUploadStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("expires_at"u8)) + { + expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("object"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - @object = new InternalUploadObject(property.Value.GetString()); continue; } - if (property.NameEquals("file"u8)) + @object = new InternalUploadObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("file"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - file = null; - continue; - } - file = OpenAIFileInfo.DeserializeOpenAIFileInfo(property.Value, options); + file = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + file = OpenAIFileInfo.DeserializeOpenAIFileInfo(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUpload( - id, - createdAt, - filename, - bytes, - purpose, - status, - expiresAt, - @object, - file, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalUpload)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUpload( + id, + createdAt, + filename, + bytes, + purpose, + status, + expiresAt, + @object, + file, + serializedAdditionalRawData); + } - InternalUpload IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalUpload(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalUpload)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalUpload)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + InternalUpload IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalUpload FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUpload(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalUpload(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalUpload)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalUpload FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUpload(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUpload.cs b/src/Generated/Models/InternalUpload.cs index fb464ded..690c8c9a 100644 --- a/src/Generated/Models/InternalUpload.cs +++ b/src/Generated/Models/InternalUpload.cs @@ -5,52 +5,51 @@ using System; using System.Collections.Generic; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalUpload { - internal partial class InternalUpload + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalUpload(string id, DateTimeOffset createdAt, string filename, int bytes, string purpose, InternalUploadStatus status, DateTimeOffset expiresAt) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(filename, nameof(filename)); + Argument.AssertNotNull(purpose, nameof(purpose)); + + Id = id; + CreatedAt = createdAt; + Filename = filename; + Bytes = bytes; + Purpose = purpose; + Status = status; + ExpiresAt = expiresAt; + } + + internal InternalUpload(string id, DateTimeOffset createdAt, string filename, int bytes, string purpose, InternalUploadStatus status, DateTimeOffset expiresAt, InternalUploadObject? @object, OpenAIFileInfo file, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalUpload(string id, DateTimeOffset createdAt, string filename, int bytes, string purpose, InternalUploadStatus status, DateTimeOffset expiresAt) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(filename, nameof(filename)); - Argument.AssertNotNull(purpose, nameof(purpose)); - - Id = id; - CreatedAt = createdAt; - Filename = filename; - Bytes = bytes; - Purpose = purpose; - Status = status; - ExpiresAt = expiresAt; - } - - internal InternalUpload(string id, DateTimeOffset createdAt, string filename, int bytes, string purpose, InternalUploadStatus status, DateTimeOffset expiresAt, InternalUploadObject? @object, OpenAIFileInfo file, IDictionary serializedAdditionalRawData) - { - Id = id; - CreatedAt = createdAt; - Filename = filename; - Bytes = bytes; - Purpose = purpose; - Status = status; - ExpiresAt = expiresAt; - Object = @object; - File = file; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalUpload() - { - } - - public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public string Filename { get; } - public int Bytes { get; } - public string Purpose { get; } - public InternalUploadStatus Status { get; } - public DateTimeOffset ExpiresAt { get; } - public InternalUploadObject? Object { get; } - public OpenAIFileInfo File { get; } + Id = id; + CreatedAt = createdAt; + Filename = filename; + Bytes = bytes; + Purpose = purpose; + Status = status; + ExpiresAt = expiresAt; + Object = @object; + File = file; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalUpload() + { + } + + public string Id { get; } + public DateTimeOffset CreatedAt { get; } + public string Filename { get; } + public int Bytes { get; } + public string Purpose { get; } + public InternalUploadStatus Status { get; } + public DateTimeOffset ExpiresAt { get; } + public InternalUploadObject? Object { get; } + public OpenAIFileInfo File { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUploadObject.cs b/src/Generated/Models/InternalUploadObject.cs index 9dacd622..dd540a6b 100644 --- a/src/Generated/Models/InternalUploadObject.cs +++ b/src/Generated/Models/InternalUploadObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal readonly partial struct InternalUploadObject : IEquatable { - internal readonly partial struct InternalUploadObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalUploadObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalUploadObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string UploadValue = "upload"; + private const string UploadValue = "upload"; - public static InternalUploadObject Upload { get; } = new InternalUploadObject(UploadValue); - public static bool operator ==(InternalUploadObject left, InternalUploadObject right) => left.Equals(right); - public static bool operator !=(InternalUploadObject left, InternalUploadObject right) => !left.Equals(right); - public static implicit operator InternalUploadObject(string value) => new InternalUploadObject(value); + public static InternalUploadObject Upload { get; } = new InternalUploadObject(UploadValue); + public static bool operator ==(InternalUploadObject left, InternalUploadObject right) => left.Equals(right); + public static bool operator !=(InternalUploadObject left, InternalUploadObject right) => !left.Equals(right); + public static implicit operator InternalUploadObject(string value) => new InternalUploadObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalUploadObject other && Equals(other); - public bool Equals(InternalUploadObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalUploadObject other && Equals(other); + public bool Equals(InternalUploadObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUploadPart.Serialization.cs b/src/Generated/Models/InternalUploadPart.Serialization.cs index c6f4c77f..ac8ae4e7 100644 --- a/src/Generated/Models/InternalUploadPart.Serialization.cs +++ b/src/Generated/Models/InternalUploadPart.Serialization.cs @@ -8,159 +8,158 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalUploadPart : IJsonModel { - internal partial class InternalUploadPart : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalUploadPart)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalUploadPart)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) - { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("upload_id") != true) - { - writer.WritePropertyName("upload_id"u8); - writer.WriteStringValue(UploadId); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("upload_id") != true) + { + writer.WritePropertyName("upload_id"u8); + writer.WriteStringValue(UploadId); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalUploadPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalUploadPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalUploadPart)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalUploadPart(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalUploadPart)} does not support reading '{format}' format."); } - internal static InternalUploadPart DeserializeInternalUploadPart(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalUploadPart(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static InternalUploadPart DeserializeInternalUploadPart(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + DateTimeOffset createdAt = default; + string uploadId = default; + InternalUploadPartObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - DateTimeOffset createdAt = default; - string uploadId = default; - InternalUploadPartObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("created_at"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("upload_id"u8)) - { - uploadId = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalUploadPartObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUploadPart(id, createdAt, uploadId, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("upload_id"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalUploadPart)} does not support writing '{options.Format}' format."); + uploadId = property.Value.GetString(); + continue; } - } - - InternalUploadPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) + { + @object = new InternalUploadPartObject(property.Value.GetString()); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalUploadPart(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalUploadPart)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalUploadPart(id, createdAt, uploadId, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalUploadPart FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUploadPart(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalUploadPart)} does not support writing '{options.Format}' format."); } + } + + InternalUploadPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalUploadPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalUploadPart)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalUploadPart FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalUploadPart(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUploadPart.cs b/src/Generated/Models/InternalUploadPart.cs index 5a723927..65481da4 100644 --- a/src/Generated/Models/InternalUploadPart.cs +++ b/src/Generated/Models/InternalUploadPart.cs @@ -5,37 +5,36 @@ using System; using System.Collections.Generic; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal partial class InternalUploadPart { - internal partial class InternalUploadPart + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalUploadPart(string id, DateTimeOffset createdAt, string uploadId) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(uploadId, nameof(uploadId)); + + Id = id; + CreatedAt = createdAt; + UploadId = uploadId; + } + + internal InternalUploadPart(string id, DateTimeOffset createdAt, string uploadId, InternalUploadPartObject @object, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalUploadPart(string id, DateTimeOffset createdAt, string uploadId) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(uploadId, nameof(uploadId)); - - Id = id; - CreatedAt = createdAt; - UploadId = uploadId; - } - - internal InternalUploadPart(string id, DateTimeOffset createdAt, string uploadId, InternalUploadPartObject @object, IDictionary serializedAdditionalRawData) - { - Id = id; - CreatedAt = createdAt; - UploadId = uploadId; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal InternalUploadPart() - { - } - - public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public string UploadId { get; } - public InternalUploadPartObject Object { get; } = InternalUploadPartObject.UploadPart; + Id = id; + CreatedAt = createdAt; + UploadId = uploadId; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal InternalUploadPart() + { + } + + public string Id { get; } + public DateTimeOffset CreatedAt { get; } + public string UploadId { get; } + public InternalUploadPartObject Object { get; } = InternalUploadPartObject.UploadPart; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUploadPartObject.cs b/src/Generated/Models/InternalUploadPartObject.cs index b790ad18..b92b52ce 100644 --- a/src/Generated/Models/InternalUploadPartObject.cs +++ b/src/Generated/Models/InternalUploadPartObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal readonly partial struct InternalUploadPartObject : IEquatable { - internal readonly partial struct InternalUploadPartObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalUploadPartObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalUploadPartObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string UploadPartValue = "upload.part"; + private const string UploadPartValue = "upload.part"; - public static InternalUploadPartObject UploadPart { get; } = new InternalUploadPartObject(UploadPartValue); - public static bool operator ==(InternalUploadPartObject left, InternalUploadPartObject right) => left.Equals(right); - public static bool operator !=(InternalUploadPartObject left, InternalUploadPartObject right) => !left.Equals(right); - public static implicit operator InternalUploadPartObject(string value) => new InternalUploadPartObject(value); + public static InternalUploadPartObject UploadPart { get; } = new InternalUploadPartObject(UploadPartValue); + public static bool operator ==(InternalUploadPartObject left, InternalUploadPartObject right) => left.Equals(right); + public static bool operator !=(InternalUploadPartObject left, InternalUploadPartObject right) => !left.Equals(right); + public static implicit operator InternalUploadPartObject(string value) => new InternalUploadPartObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalUploadPartObject other && Equals(other); - public bool Equals(InternalUploadPartObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalUploadPartObject other && Equals(other); + public bool Equals(InternalUploadPartObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalUploadStatus.cs b/src/Generated/Models/InternalUploadStatus.cs index 4ac5876d..49eaa455 100644 --- a/src/Generated/Models/InternalUploadStatus.cs +++ b/src/Generated/Models/InternalUploadStatus.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +internal readonly partial struct InternalUploadStatus : IEquatable { - internal readonly partial struct InternalUploadStatus : IEquatable + private readonly string _value; + + public InternalUploadStatus(string value) { - private readonly string _value; - - public InternalUploadStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string PendingValue = "pending"; - private const string CompletedValue = "completed"; - private const string CancelledValue = "cancelled"; - private const string ExpiredValue = "expired"; - - public static InternalUploadStatus Pending { get; } = new InternalUploadStatus(PendingValue); - public static InternalUploadStatus Completed { get; } = new InternalUploadStatus(CompletedValue); - public static InternalUploadStatus Cancelled { get; } = new InternalUploadStatus(CancelledValue); - public static InternalUploadStatus Expired { get; } = new InternalUploadStatus(ExpiredValue); - public static bool operator ==(InternalUploadStatus left, InternalUploadStatus right) => left.Equals(right); - public static bool operator !=(InternalUploadStatus left, InternalUploadStatus right) => !left.Equals(right); - public static implicit operator InternalUploadStatus(string value) => new InternalUploadStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalUploadStatus other && Equals(other); - public bool Equals(InternalUploadStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string PendingValue = "pending"; + private const string CompletedValue = "completed"; + private const string CancelledValue = "cancelled"; + private const string ExpiredValue = "expired"; + + public static InternalUploadStatus Pending { get; } = new InternalUploadStatus(PendingValue); + public static InternalUploadStatus Completed { get; } = new InternalUploadStatus(CompletedValue); + public static InternalUploadStatus Cancelled { get; } = new InternalUploadStatus(CancelledValue); + public static InternalUploadStatus Expired { get; } = new InternalUploadStatus(ExpiredValue); + public static bool operator ==(InternalUploadStatus left, InternalUploadStatus right) => left.Equals(right); + public static bool operator !=(InternalUploadStatus left, InternalUploadStatus right) => !left.Equals(right); + public static implicit operator InternalUploadStatus(string value) => new InternalUploadStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalUploadStatus other && Equals(other); + public bool Equals(InternalUploadStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.Serialization.cs b/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.Serialization.cs index fa75b3b8..bba13d8f 100644 --- a/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.Serialization.cs +++ b/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.Serialization.cs @@ -8,176 +8,175 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalVectorStoreFileBatchObjectFileCounts : IJsonModel { - internal partial class InternalVectorStoreFileBatchObjectFileCounts : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("in_progress") != true) - { - writer.WritePropertyName("in_progress"u8); - writer.WriteNumberValue(InProgress); - } - if (SerializedAdditionalRawData?.ContainsKey("completed") != true) - { - writer.WritePropertyName("completed"u8); - writer.WriteNumberValue(Completed); - } - if (SerializedAdditionalRawData?.ContainsKey("failed") != true) - { - writer.WritePropertyName("failed"u8); - writer.WriteNumberValue(Failed); - } - if (SerializedAdditionalRawData?.ContainsKey("cancelled") != true) - { - writer.WritePropertyName("cancelled"u8); - writer.WriteNumberValue(Cancelled); - } - if (SerializedAdditionalRawData?.ContainsKey("total") != true) - { - writer.WritePropertyName("total"u8); - writer.WriteNumberValue(Total); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("in_progress") != true) + { + writer.WritePropertyName("in_progress"u8); + writer.WriteNumberValue(InProgress); + } + if (SerializedAdditionalRawData?.ContainsKey("completed") != true) + { + writer.WritePropertyName("completed"u8); + writer.WriteNumberValue(Completed); + } + if (SerializedAdditionalRawData?.ContainsKey("failed") != true) + { + writer.WritePropertyName("failed"u8); + writer.WriteNumberValue(Failed); + } + if (SerializedAdditionalRawData?.ContainsKey("cancelled") != true) + { + writer.WritePropertyName("cancelled"u8); + writer.WriteNumberValue(Cancelled); + } + if (SerializedAdditionalRawData?.ContainsKey("total") != true) + { + writer.WritePropertyName("total"u8); + writer.WriteNumberValue(Total); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - InternalVectorStoreFileBatchObjectFileCounts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalVectorStoreFileBatchObjectFileCounts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalVectorStoreFileBatchObjectFileCounts(document.RootElement, options); + throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support reading '{format}' format."); } - internal static InternalVectorStoreFileBatchObjectFileCounts DeserializeInternalVectorStoreFileBatchObjectFileCounts(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalVectorStoreFileBatchObjectFileCounts(document.RootElement, options); + } + + internal static InternalVectorStoreFileBatchObjectFileCounts DeserializeInternalVectorStoreFileBatchObjectFileCounts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int inProgress = default; + int completed = default; + int failed = default; + int cancelled = default; + int total = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("in_progress"u8)) { - return null; + inProgress = property.Value.GetInt32(); + continue; } - int inProgress = default; - int completed = default; - int failed = default; - int cancelled = default; - int total = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("completed"u8)) { - if (property.NameEquals("in_progress"u8)) - { - inProgress = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("completed"u8)) - { - completed = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("failed"u8)) - { - failed = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("cancelled"u8)) - { - cancelled = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total"u8)) - { - total = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + completed = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new InternalVectorStoreFileBatchObjectFileCounts( - inProgress, - completed, - failed, - cancelled, - total, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("failed"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support writing '{options.Format}' format."); + failed = property.Value.GetInt32(); + continue; } - } - - InternalVectorStoreFileBatchObjectFileCounts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("cancelled"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalVectorStoreFileBatchObjectFileCounts(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support reading '{options.Format}' format."); + cancelled = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("total"u8)) + { + total = property.Value.GetInt32(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new InternalVectorStoreFileBatchObjectFileCounts( + inProgress, + completed, + failed, + cancelled, + total, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static InternalVectorStoreFileBatchObjectFileCounts FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalVectorStoreFileBatchObjectFileCounts(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + InternalVectorStoreFileBatchObjectFileCounts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalVectorStoreFileBatchObjectFileCounts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalVectorStoreFileBatchObjectFileCounts)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static InternalVectorStoreFileBatchObjectFileCounts FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInternalVectorStoreFileBatchObjectFileCounts(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.cs b/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.cs index 03849395..eea5ca1a 100644 --- a/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.cs +++ b/src/Generated/Models/InternalVectorStoreFileBatchObjectFileCounts.cs @@ -5,38 +5,37 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal partial class InternalVectorStoreFileBatchObjectFileCounts { - internal partial class InternalVectorStoreFileBatchObjectFileCounts + internal IDictionary SerializedAdditionalRawData { get; set; } + internal InternalVectorStoreFileBatchObjectFileCounts(int inProgress, int completed, int failed, int cancelled, int total) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal InternalVectorStoreFileBatchObjectFileCounts(int inProgress, int completed, int failed, int cancelled, int total) - { - InProgress = inProgress; - Completed = completed; - Failed = failed; - Cancelled = cancelled; - Total = total; - } - - internal InternalVectorStoreFileBatchObjectFileCounts(int inProgress, int completed, int failed, int cancelled, int total, IDictionary serializedAdditionalRawData) - { - InProgress = inProgress; - Completed = completed; - Failed = failed; - Cancelled = cancelled; - Total = total; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + } - internal InternalVectorStoreFileBatchObjectFileCounts() - { - } + internal InternalVectorStoreFileBatchObjectFileCounts(int inProgress, int completed, int failed, int cancelled, int total, IDictionary serializedAdditionalRawData) + { + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int InProgress { get; } - public int Completed { get; } - public int Failed { get; } - public int Cancelled { get; } - public int Total { get; } + internal InternalVectorStoreFileBatchObjectFileCounts() + { } -} + + public int InProgress { get; } + public int Completed { get; } + public int Failed { get; } + public int Cancelled { get; } + public int Total { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/InternalVectorStoreFileBatchObjectObject.cs b/src/Generated/Models/InternalVectorStoreFileBatchObjectObject.cs index baa95d6a..5230f1a1 100644 --- a/src/Generated/Models/InternalVectorStoreFileBatchObjectObject.cs +++ b/src/Generated/Models/InternalVectorStoreFileBatchObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalVectorStoreFileBatchObjectObject : IEquatable { - internal readonly partial struct InternalVectorStoreFileBatchObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalVectorStoreFileBatchObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalVectorStoreFileBatchObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string VectorStoreFilesBatchValue = "vector_store.files_batch"; + private const string VectorStoreFilesBatchValue = "vector_store.files_batch"; - public static InternalVectorStoreFileBatchObjectObject VectorStoreFilesBatch { get; } = new InternalVectorStoreFileBatchObjectObject(VectorStoreFilesBatchValue); - public static bool operator ==(InternalVectorStoreFileBatchObjectObject left, InternalVectorStoreFileBatchObjectObject right) => left.Equals(right); - public static bool operator !=(InternalVectorStoreFileBatchObjectObject left, InternalVectorStoreFileBatchObjectObject right) => !left.Equals(right); - public static implicit operator InternalVectorStoreFileBatchObjectObject(string value) => new InternalVectorStoreFileBatchObjectObject(value); + public static InternalVectorStoreFileBatchObjectObject VectorStoreFilesBatch { get; } = new InternalVectorStoreFileBatchObjectObject(VectorStoreFilesBatchValue); + public static bool operator ==(InternalVectorStoreFileBatchObjectObject left, InternalVectorStoreFileBatchObjectObject right) => left.Equals(right); + public static bool operator !=(InternalVectorStoreFileBatchObjectObject left, InternalVectorStoreFileBatchObjectObject right) => !left.Equals(right); + public static implicit operator InternalVectorStoreFileBatchObjectObject(string value) => new InternalVectorStoreFileBatchObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalVectorStoreFileBatchObjectObject other && Equals(other); - public bool Equals(InternalVectorStoreFileBatchObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalVectorStoreFileBatchObjectObject other && Equals(other); + public bool Equals(InternalVectorStoreFileBatchObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalVectorStoreFileObjectObject.cs b/src/Generated/Models/InternalVectorStoreFileObjectObject.cs index 89fbddec..35c281ef 100644 --- a/src/Generated/Models/InternalVectorStoreFileObjectObject.cs +++ b/src/Generated/Models/InternalVectorStoreFileObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalVectorStoreFileObjectObject : IEquatable { - internal readonly partial struct InternalVectorStoreFileObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalVectorStoreFileObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalVectorStoreFileObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string VectorStoreFileValue = "vector_store.file"; + private const string VectorStoreFileValue = "vector_store.file"; - public static InternalVectorStoreFileObjectObject VectorStoreFile { get; } = new InternalVectorStoreFileObjectObject(VectorStoreFileValue); - public static bool operator ==(InternalVectorStoreFileObjectObject left, InternalVectorStoreFileObjectObject right) => left.Equals(right); - public static bool operator !=(InternalVectorStoreFileObjectObject left, InternalVectorStoreFileObjectObject right) => !left.Equals(right); - public static implicit operator InternalVectorStoreFileObjectObject(string value) => new InternalVectorStoreFileObjectObject(value); + public static InternalVectorStoreFileObjectObject VectorStoreFile { get; } = new InternalVectorStoreFileObjectObject(VectorStoreFileValue); + public static bool operator ==(InternalVectorStoreFileObjectObject left, InternalVectorStoreFileObjectObject right) => left.Equals(right); + public static bool operator !=(InternalVectorStoreFileObjectObject left, InternalVectorStoreFileObjectObject right) => !left.Equals(right); + public static implicit operator InternalVectorStoreFileObjectObject(string value) => new InternalVectorStoreFileObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalVectorStoreFileObjectObject other && Equals(other); - public bool Equals(InternalVectorStoreFileObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalVectorStoreFileObjectObject other && Equals(other); + public bool Equals(InternalVectorStoreFileObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/InternalVectorStoreObjectObject.cs b/src/Generated/Models/InternalVectorStoreObjectObject.cs index f65258a8..8c1aa06d 100644 --- a/src/Generated/Models/InternalVectorStoreObjectObject.cs +++ b/src/Generated/Models/InternalVectorStoreObjectObject.cs @@ -5,30 +5,29 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal readonly partial struct InternalVectorStoreObjectObject : IEquatable { - internal readonly partial struct InternalVectorStoreObjectObject : IEquatable - { - private readonly string _value; + private readonly string _value; - public InternalVectorStoreObjectObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public InternalVectorStoreObjectObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string VectorStoreValue = "vector_store"; + private const string VectorStoreValue = "vector_store"; - public static InternalVectorStoreObjectObject VectorStore { get; } = new InternalVectorStoreObjectObject(VectorStoreValue); - public static bool operator ==(InternalVectorStoreObjectObject left, InternalVectorStoreObjectObject right) => left.Equals(right); - public static bool operator !=(InternalVectorStoreObjectObject left, InternalVectorStoreObjectObject right) => !left.Equals(right); - public static implicit operator InternalVectorStoreObjectObject(string value) => new InternalVectorStoreObjectObject(value); + public static InternalVectorStoreObjectObject VectorStore { get; } = new InternalVectorStoreObjectObject(VectorStoreValue); + public static bool operator ==(InternalVectorStoreObjectObject left, InternalVectorStoreObjectObject right) => left.Equals(right); + public static bool operator !=(InternalVectorStoreObjectObject left, InternalVectorStoreObjectObject right) => !left.Equals(right); + public static implicit operator InternalVectorStoreObjectObject(string value) => new InternalVectorStoreObjectObject(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalVectorStoreObjectObject other && Equals(other); - public bool Equals(InternalVectorStoreObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalVectorStoreObjectObject other && Equals(other); + public bool Equals(InternalVectorStoreObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/MessageCollectionOrder.cs b/src/Generated/Models/MessageCollectionOrder.cs index 78595483..5d8f7e0c 100644 --- a/src/Generated/Models/MessageCollectionOrder.cs +++ b/src/Generated/Models/MessageCollectionOrder.cs @@ -5,29 +5,28 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct MessageCollectionOrder : IEquatable { - public readonly partial struct MessageCollectionOrder : IEquatable + private readonly string _value; + + public MessageCollectionOrder(string value) { - private readonly string _value; - - public MessageCollectionOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AscendingValue = "asc"; - private const string DescendingValue = "desc"; - public static bool operator ==(MessageCollectionOrder left, MessageCollectionOrder right) => left.Equals(right); - public static bool operator !=(MessageCollectionOrder left, MessageCollectionOrder right) => !left.Equals(right); - public static implicit operator MessageCollectionOrder(string value) => new MessageCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageCollectionOrder other && Equals(other); - public bool Equals(MessageCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AscendingValue = "asc"; + private const string DescendingValue = "desc"; + public static bool operator ==(MessageCollectionOrder left, MessageCollectionOrder right) => left.Equals(right); + public static bool operator !=(MessageCollectionOrder left, MessageCollectionOrder right) => !left.Equals(right); + public static implicit operator MessageCollectionOrder(string value) => new MessageCollectionOrder(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageCollectionOrder other && Equals(other); + public bool Equals(MessageCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/MessageContent.Serialization.cs b/src/Generated/Models/MessageContent.Serialization.cs index 8f003079..35209be4 100644 --- a/src/Generated/Models/MessageContent.Serialization.cs +++ b/src/Generated/Models/MessageContent.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageContent : IJsonModel { - public partial class MessageContent : IJsonModel + MessageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - MessageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageContent(document.RootElement, options); + throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageContent(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - MessageContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMessageContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + MessageContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static MessageContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeMessageContent(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageContent)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static MessageContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageContent(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/MessageContent.cs b/src/Generated/Models/MessageContent.cs index cee79aae..7438c0a7 100644 --- a/src/Generated/Models/MessageContent.cs +++ b/src/Generated/Models/MessageContent.cs @@ -5,15 +5,14 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public abstract partial class MessageContent { - public abstract partial class MessageContent - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal MessageContent(IDictionary serializedAdditionalRawData) - { - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal MessageContent(IDictionary serializedAdditionalRawData) + { + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/MessageCreationAttachment.Serialization.cs b/src/Generated/Models/MessageCreationAttachment.Serialization.cs index 8ab9a3be..3d5ab6ab 100644 --- a/src/Generated/Models/MessageCreationAttachment.Serialization.cs +++ b/src/Generated/Models/MessageCreationAttachment.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageCreationAttachment : IJsonModel { - public partial class MessageCreationAttachment : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true) - { - writer.WritePropertyName("tools"u8); - SerializeTools(writer, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true) + { + writer.WritePropertyName("tools"u8); + SerializeTools(writer, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - MessageCreationAttachment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + MessageCreationAttachment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageCreationAttachment(document.RootElement, options); + throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support reading '{format}' format."); } - internal static MessageCreationAttachment DeserializeMessageCreationAttachment(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageCreationAttachment(document.RootElement, options); + } + + internal static MessageCreationAttachment DeserializeMessageCreationAttachment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IReadOnlyList tools = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - return null; + fileId = property.Value.GetString(); + continue; } - string fileId = default; - IReadOnlyList tools = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("tools"u8)) { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("tools"u8)) - { - DeserializeTools(property, ref tools); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + DeserializeTools(property, ref tools); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new MessageCreationAttachment(fileId, tools, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new MessageCreationAttachment(fileId, tools, serializedAdditionalRawData); + } - MessageCreationAttachment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMessageCreationAttachment(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + MessageCreationAttachment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static MessageCreationAttachment FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeMessageCreationAttachment(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageCreationAttachment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageCreationAttachment)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static MessageCreationAttachment FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageCreationAttachment(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/MessageCreationAttachment.cs b/src/Generated/Models/MessageCreationAttachment.cs index 3def69b5..38f0293a 100644 --- a/src/Generated/Models/MessageCreationAttachment.cs +++ b/src/Generated/Models/MessageCreationAttachment.cs @@ -6,31 +6,30 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageCreationAttachment { - public partial class MessageCreationAttachment + internal IDictionary SerializedAdditionalRawData { get; set; } + public MessageCreationAttachment(string fileId, IEnumerable tools) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(tools, nameof(tools)); + + FileId = fileId; + Tools = tools.ToList(); + } + + internal MessageCreationAttachment(string fileId, IReadOnlyList tools, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - public MessageCreationAttachment(string fileId, IEnumerable tools) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - Argument.AssertNotNull(tools, nameof(tools)); - - FileId = fileId; - Tools = tools.ToList(); - } - - internal MessageCreationAttachment(string fileId, IReadOnlyList tools, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Tools = tools; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal MessageCreationAttachment() - { - } - - public string FileId { get; } + FileId = fileId; + Tools = tools; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal MessageCreationAttachment() + { + } + + public string FileId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/MessageCreationOptions.Serialization.cs b/src/Generated/Models/MessageCreationOptions.Serialization.cs index cec07156..aebe5487 100644 --- a/src/Generated/Models/MessageCreationOptions.Serialization.cs +++ b/src/Generated/Models/MessageCreationOptions.Serialization.cs @@ -8,207 +8,206 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageCreationOptions : IJsonModel { - public partial class MessageCreationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("role") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("role") != true) + { + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("content") != true) + { + writer.WritePropertyName("content"u8); + SerializeContent(writer, options); + } + if (SerializedAdditionalRawData?.ContainsKey("attachments") != true && Optional.IsCollectionDefined(Attachments)) + { + if (Attachments != null) { - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); + writer.WritePropertyName("attachments"u8); + writer.WriteStartArray(); + foreach (var item in Attachments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("content") != true) + else { - writer.WritePropertyName("content"u8); - SerializeContent(writer, options); + writer.WriteNull("attachments"); } - if (SerializedAdditionalRawData?.ContainsKey("attachments") != true && Optional.IsCollectionDefined(Attachments)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (Attachments != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("attachments"u8); - writer.WriteStartArray(); - foreach (var item in Attachments) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("attachments"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + else { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - MessageCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + MessageCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageCreationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support reading '{format}' format."); } - internal static MessageCreationOptions DeserializeMessageCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageCreationOptions(document.RootElement, options); + } + + internal static MessageCreationOptions DeserializeMessageCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + IList content = default; + IList attachments = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("role"u8)) { - return null; + role = property.Value.GetString().ToMessageRole(); + continue; } - MessageRole role = default; - IList content = default; - IList attachments = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("content"u8)) { - if (property.NameEquals("role"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - role = property.Value.GetString().ToMessageRole(); - continue; + array.Add(MessageContent.DeserializeMessageContent(item, options)); } - if (property.NameEquals("content"u8)) + content = array; + continue; + } + if (property.NameEquals("attachments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageContent.DeserializeMessageContent(item, options)); - } - content = array; continue; } - if (property.NameEquals("attachments"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageCreationAttachment.DeserializeMessageCreationAttachment(item, options)); - } - attachments = array; - continue; + array.Add(MessageCreationAttachment.DeserializeMessageCreationAttachment(item, options)); } - if (property.NameEquals("metadata"u8)) + attachments = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new MessageCreationOptions(role, content, attachments ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new MessageCreationOptions(role, content, attachments ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - MessageCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMessageCreationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + MessageCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static MessageCreationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeMessageCreationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageCreationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static MessageCreationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageCreationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/MessageCreationOptions.cs b/src/Generated/Models/MessageCreationOptions.cs index 12334462..3fc2e7b5 100644 --- a/src/Generated/Models/MessageCreationOptions.cs +++ b/src/Generated/Models/MessageCreationOptions.cs @@ -6,21 +6,20 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageCreationOptions { - public partial class MessageCreationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal MessageCreationOptions(MessageRole role, IList content, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - Role = role; - Content = content; - Attachments = attachments; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public IList Attachments { get; set; } - public IDictionary Metadata { get; set; } + internal MessageCreationOptions(MessageRole role, IList content, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + Attachments = attachments; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public IList Attachments { get; set; } + public IDictionary Metadata { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/MessageDeletionResult.Serialization.cs b/src/Generated/Models/MessageDeletionResult.Serialization.cs index 0025d8dc..43a56313 100644 --- a/src/Generated/Models/MessageDeletionResult.Serialization.cs +++ b/src/Generated/Models/MessageDeletionResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageDeletionResult : IJsonModel { - public partial class MessageDeletionResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(MessageId); - } - if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) - { - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(MessageId); + } + if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) + { + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - MessageDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + MessageDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageDeletionResult(document.RootElement, options); + throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support reading '{format}' format."); } - internal static MessageDeletionResult DeserializeMessageDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeletionResult(document.RootElement, options); + } + + internal static MessageDeletionResult DeserializeMessageDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalDeleteMessageResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - bool deleted = default; - InternalDeleteMessageResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("deleted"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalDeleteMessageResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + deleted = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new MessageDeletionResult(id, deleted, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support writing '{options.Format}' format."); + @object = new InternalDeleteMessageResponseObject(property.Value.GetString()); + continue; } - } - - MessageDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMessageDeletionResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeletionResult(id, deleted, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static MessageDeletionResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeMessageDeletionResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support writing '{options.Format}' format."); } + } + + MessageDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeletionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeletionResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static MessageDeletionResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeletionResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/MessageDeletionResult.cs b/src/Generated/Models/MessageDeletionResult.cs index c99f9922..1cf6347b 100644 --- a/src/Generated/Models/MessageDeletionResult.cs +++ b/src/Generated/Models/MessageDeletionResult.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageDeletionResult { - public partial class MessageDeletionResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal MessageDeletionResult(string messageId, bool deleted) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal MessageDeletionResult(string messageId, bool deleted) - { - Argument.AssertNotNull(messageId, nameof(messageId)); + Argument.AssertNotNull(messageId, nameof(messageId)); - MessageId = messageId; - Deleted = deleted; - } + MessageId = messageId; + Deleted = deleted; + } - internal MessageDeletionResult(string messageId, bool deleted, InternalDeleteMessageResponseObject @object, IDictionary serializedAdditionalRawData) - { - MessageId = messageId; - Deleted = deleted; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal MessageDeletionResult(string messageId, bool deleted, InternalDeleteMessageResponseObject @object, IDictionary serializedAdditionalRawData) + { + MessageId = messageId; + Deleted = deleted; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal MessageDeletionResult() - { - } - public bool Deleted { get; } + internal MessageDeletionResult() + { } -} + public bool Deleted { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/MessageFailureDetails.Serialization.cs b/src/Generated/Models/MessageFailureDetails.Serialization.cs index 50740a3c..5b4aa13b 100644 --- a/src/Generated/Models/MessageFailureDetails.Serialization.cs +++ b/src/Generated/Models/MessageFailureDetails.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageFailureDetails : IJsonModel { - public partial class MessageFailureDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("reason") != true) - { - writer.WritePropertyName("reason"u8); - writer.WriteStringValue(Reason.ToString()); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support writing '{format}' format."); } - MessageFailureDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("reason") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageFailureDetails(document.RootElement, options); + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.ToString()); } - - internal static MessageFailureDetails DeserializeMessageFailureDetails(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - MessageFailureReason reason = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("reason"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - reason = new MessageFailureReason(property.Value.GetString()); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new MessageFailureDetails(reason, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + MessageFailureDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support reading '{format}' format."); } - MessageFailureDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageFailureDetails(document.RootElement, options); + } + + internal static MessageFailureDetails DeserializeMessageFailureDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageFailureReason reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reason"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMessageFailureDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support reading '{options.Format}' format."); + reason = new MessageFailureReason(property.Value.GetString()); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new MessageFailureDetails(reason, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static MessageFailureDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeMessageFailureDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support writing '{options.Format}' format."); } + } + + MessageFailureDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageFailureDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageFailureDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static MessageFailureDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageFailureDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/MessageFailureDetails.cs b/src/Generated/Models/MessageFailureDetails.cs index 9c6b6e8e..c7cd0e8b 100644 --- a/src/Generated/Models/MessageFailureDetails.cs +++ b/src/Generated/Models/MessageFailureDetails.cs @@ -5,26 +5,25 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageFailureDetails { - public partial class MessageFailureDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + internal MessageFailureDetails(MessageFailureReason reason) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal MessageFailureDetails(MessageFailureReason reason) - { - Reason = reason; - } - - internal MessageFailureDetails(MessageFailureReason reason, IDictionary serializedAdditionalRawData) - { - Reason = reason; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Reason = reason; + } - internal MessageFailureDetails() - { - } + internal MessageFailureDetails(MessageFailureReason reason, IDictionary serializedAdditionalRawData) + { + Reason = reason; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public MessageFailureReason Reason { get; } + internal MessageFailureDetails() + { } -} + + public MessageFailureReason Reason { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/MessageFailureReason.cs b/src/Generated/Models/MessageFailureReason.cs index ac0b0a02..6c7adfa2 100644 --- a/src/Generated/Models/MessageFailureReason.cs +++ b/src/Generated/Models/MessageFailureReason.cs @@ -5,38 +5,37 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct MessageFailureReason : IEquatable { - public readonly partial struct MessageFailureReason : IEquatable + private readonly string _value; + + public MessageFailureReason(string value) { - private readonly string _value; - - public MessageFailureReason(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ContentFilterValue = "content_filter"; - private const string MaxTokensValue = "max_tokens"; - private const string RunCancelledValue = "run_cancelled"; - private const string RunExpiredValue = "run_expired"; - private const string RunFailedValue = "run_failed"; - - public static MessageFailureReason ContentFilter { get; } = new MessageFailureReason(ContentFilterValue); - public static MessageFailureReason MaxTokens { get; } = new MessageFailureReason(MaxTokensValue); - public static MessageFailureReason RunCancelled { get; } = new MessageFailureReason(RunCancelledValue); - public static MessageFailureReason RunExpired { get; } = new MessageFailureReason(RunExpiredValue); - public static MessageFailureReason RunFailed { get; } = new MessageFailureReason(RunFailedValue); - public static bool operator ==(MessageFailureReason left, MessageFailureReason right) => left.Equals(right); - public static bool operator !=(MessageFailureReason left, MessageFailureReason right) => !left.Equals(right); - public static implicit operator MessageFailureReason(string value) => new MessageFailureReason(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageFailureReason other && Equals(other); - public bool Equals(MessageFailureReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string ContentFilterValue = "content_filter"; + private const string MaxTokensValue = "max_tokens"; + private const string RunCancelledValue = "run_cancelled"; + private const string RunExpiredValue = "run_expired"; + private const string RunFailedValue = "run_failed"; + + public static MessageFailureReason ContentFilter { get; } = new MessageFailureReason(ContentFilterValue); + public static MessageFailureReason MaxTokens { get; } = new MessageFailureReason(MaxTokensValue); + public static MessageFailureReason RunCancelled { get; } = new MessageFailureReason(RunCancelledValue); + public static MessageFailureReason RunExpired { get; } = new MessageFailureReason(RunExpiredValue); + public static MessageFailureReason RunFailed { get; } = new MessageFailureReason(RunFailedValue); + public static bool operator ==(MessageFailureReason left, MessageFailureReason right) => left.Equals(right); + public static bool operator !=(MessageFailureReason left, MessageFailureReason right) => !left.Equals(right); + public static implicit operator MessageFailureReason(string value) => new MessageFailureReason(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageFailureReason other && Equals(other); + public bool Equals(MessageFailureReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/MessageModificationOptions.Serialization.cs b/src/Generated/Models/MessageModificationOptions.Serialization.cs index f5b28713..f7d2eb19 100644 --- a/src/Generated/Models/MessageModificationOptions.Serialization.cs +++ b/src/Generated/Models/MessageModificationOptions.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageModificationOptions : IJsonModel { - public partial class MessageModificationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("metadata"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("metadata"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - MessageModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + MessageModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageModificationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support reading '{format}' format."); } - internal static MessageModificationOptions DeserializeMessageModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageModificationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static MessageModificationOptions DeserializeMessageModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadata"u8)) { - if (property.NameEquals("metadata"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new MessageModificationOptions(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new MessageModificationOptions(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - MessageModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMessageModificationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + MessageModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static MessageModificationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeMessageModificationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageModificationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageModificationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static MessageModificationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageModificationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/MessageModificationOptions.cs b/src/Generated/Models/MessageModificationOptions.cs index 5c53d223..9b03c0ee 100644 --- a/src/Generated/Models/MessageModificationOptions.cs +++ b/src/Generated/Models/MessageModificationOptions.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class MessageModificationOptions { - public partial class MessageModificationOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public MessageModificationOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public MessageModificationOptions() - { - Metadata = new ChangeTrackingDictionary(); - } - - internal MessageModificationOptions(IDictionary metadata, IDictionary serializedAdditionalRawData) - { - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Metadata = new ChangeTrackingDictionary(); + } - public IDictionary Metadata { get; set; } + internal MessageModificationOptions(IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IDictionary Metadata { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/MessageRole.Serialization.cs b/src/Generated/Models/MessageRole.Serialization.cs index 6d77ee63..c03861df 100644 --- a/src/Generated/Models/MessageRole.Serialization.cs +++ b/src/Generated/Models/MessageRole.Serialization.cs @@ -4,22 +4,21 @@ using System; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal static partial class MessageRoleExtensions { - internal static partial class MessageRoleExtensions + public static string ToSerialString(this MessageRole value) => value switch { - public static string ToSerialString(this MessageRole value) => value switch - { - MessageRole.User => "user", - MessageRole.Assistant => "assistant", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MessageRole value.") - }; + MessageRole.User => "user", + MessageRole.Assistant => "assistant", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MessageRole value.") + }; - public static MessageRole ToMessageRole(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "user")) return MessageRole.User; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "assistant")) return MessageRole.Assistant; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MessageRole value."); - } + public static MessageRole ToMessageRole(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "user")) return MessageRole.User; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "assistant")) return MessageRole.Assistant; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MessageRole value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/MessageStatus.cs b/src/Generated/Models/MessageStatus.cs index 86f1d414..e0f24d07 100644 --- a/src/Generated/Models/MessageStatus.cs +++ b/src/Generated/Models/MessageStatus.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct MessageStatus : IEquatable { - public readonly partial struct MessageStatus : IEquatable + private readonly string _value; + + public MessageStatus(string value) { - private readonly string _value; - - public MessageStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string IncompleteValue = "incomplete"; - private const string CompletedValue = "completed"; - - public static MessageStatus InProgress { get; } = new MessageStatus(InProgressValue); - public static MessageStatus Incomplete { get; } = new MessageStatus(IncompleteValue); - public static MessageStatus Completed { get; } = new MessageStatus(CompletedValue); - public static bool operator ==(MessageStatus left, MessageStatus right) => left.Equals(right); - public static bool operator !=(MessageStatus left, MessageStatus right) => !left.Equals(right); - public static implicit operator MessageStatus(string value) => new MessageStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageStatus other && Equals(other); - public bool Equals(MessageStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string InProgressValue = "in_progress"; + private const string IncompleteValue = "incomplete"; + private const string CompletedValue = "completed"; + + public static MessageStatus InProgress { get; } = new MessageStatus(InProgressValue); + public static MessageStatus Incomplete { get; } = new MessageStatus(IncompleteValue); + public static MessageStatus Completed { get; } = new MessageStatus(CompletedValue); + public static bool operator ==(MessageStatus left, MessageStatus right) => left.Equals(right); + public static bool operator !=(MessageStatus left, MessageStatus right) => !left.Equals(right); + public static implicit operator MessageStatus(string value) => new MessageStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageStatus other && Equals(other); + public bool Equals(MessageStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/ModelDeletionResult.Serialization.cs b/src/Generated/Models/ModelDeletionResult.Serialization.cs index 0339219c..fe79ad23 100644 --- a/src/Generated/Models/ModelDeletionResult.Serialization.cs +++ b/src/Generated/Models/ModelDeletionResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Models +namespace OpenAI.Models; + +public partial class ModelDeletionResult : IJsonModel { - public partial class ModelDeletionResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(ModelId); - } - if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) - { - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(ModelId); + } + if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) + { + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ModelDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ModelDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeModelDeletionResult(document.RootElement, options); + throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support reading '{format}' format."); } - internal static ModelDeletionResult DeserializeModelDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelDeletionResult(document.RootElement, options); + } + + internal static ModelDeletionResult DeserializeModelDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalDeleteModelResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - bool deleted = default; - InternalDeleteModelResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("deleted"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalDeleteModelResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + deleted = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ModelDeletionResult(id, deleted, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support writing '{options.Format}' format."); + @object = new InternalDeleteModelResponseObject(property.Value.GetString()); + continue; } - } - - ModelDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeModelDeletionResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ModelDeletionResult(id, deleted, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ModelDeletionResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeModelDeletionResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support writing '{options.Format}' format."); } + } + + ModelDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModelDeletionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelDeletionResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ModelDeletionResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeModelDeletionResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ModelDeletionResult.cs b/src/Generated/Models/ModelDeletionResult.cs index d70e155f..7cfdeca3 100644 --- a/src/Generated/Models/ModelDeletionResult.cs +++ b/src/Generated/Models/ModelDeletionResult.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.Models +namespace OpenAI.Models; + +public partial class ModelDeletionResult { - public partial class ModelDeletionResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ModelDeletionResult(string modelId, bool deleted) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ModelDeletionResult(string modelId, bool deleted) - { - Argument.AssertNotNull(modelId, nameof(modelId)); + Argument.AssertNotNull(modelId, nameof(modelId)); - ModelId = modelId; - Deleted = deleted; - } + ModelId = modelId; + Deleted = deleted; + } - internal ModelDeletionResult(string modelId, bool deleted, InternalDeleteModelResponseObject @object, IDictionary serializedAdditionalRawData) - { - ModelId = modelId; - Deleted = deleted; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ModelDeletionResult(string modelId, bool deleted, InternalDeleteModelResponseObject @object, IDictionary serializedAdditionalRawData) + { + ModelId = modelId; + Deleted = deleted; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ModelDeletionResult() - { - } - public bool Deleted { get; } + internal ModelDeletionResult() + { } -} + public bool Deleted { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationCategories.Serialization.cs b/src/Generated/Models/ModerationCategories.Serialization.cs index f8bc1c57..6a5886f0 100644 --- a/src/Generated/Models/ModerationCategories.Serialization.cs +++ b/src/Generated/Models/ModerationCategories.Serialization.cs @@ -8,248 +8,247 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationCategories : IJsonModel { - public partial class ModerationCategories : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModerationCategories)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("hate") != true) + { + writer.WritePropertyName("hate"u8); + writer.WriteBooleanValue(Hate); + } + if (SerializedAdditionalRawData?.ContainsKey("hate/threatening") != true) + { + writer.WritePropertyName("hate/threatening"u8); + writer.WriteBooleanValue(HateThreatening); + } + if (SerializedAdditionalRawData?.ContainsKey("harassment") != true) + { + writer.WritePropertyName("harassment"u8); + writer.WriteBooleanValue(Harassment); + } + if (SerializedAdditionalRawData?.ContainsKey("harassment/threatening") != true) + { + writer.WritePropertyName("harassment/threatening"u8); + writer.WriteBooleanValue(HarassmentThreatening); + } + if (SerializedAdditionalRawData?.ContainsKey("self-harm") != true) + { + writer.WritePropertyName("self-harm"u8); + writer.WriteBooleanValue(SelfHarm); + } + if (SerializedAdditionalRawData?.ContainsKey("self-harm/intent") != true) + { + writer.WritePropertyName("self-harm/intent"u8); + writer.WriteBooleanValue(SelfHarmIntent); + } + if (SerializedAdditionalRawData?.ContainsKey("self-harm/instructions") != true) + { + writer.WritePropertyName("self-harm/instructions"u8); + writer.WriteBooleanValue(SelfHarmInstructions); + } + if (SerializedAdditionalRawData?.ContainsKey("sexual") != true) + { + writer.WritePropertyName("sexual"u8); + writer.WriteBooleanValue(Sexual); + } + if (SerializedAdditionalRawData?.ContainsKey("sexual/minors") != true) + { + writer.WritePropertyName("sexual/minors"u8); + writer.WriteBooleanValue(SexualMinors); + } + if (SerializedAdditionalRawData?.ContainsKey("violence") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("violence"u8); + writer.WriteBooleanValue(Violence); + } + if (SerializedAdditionalRawData?.ContainsKey("violence/graphic") != true) + { + writer.WritePropertyName("violence/graphic"u8); + writer.WriteBooleanValue(ViolenceGraphic); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - throw new FormatException($"The model {nameof(ModerationCategories)} does not support writing '{format}' format."); + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif } + } + writer.WriteEndObject(); + } + + ModerationCategories IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModerationCategories)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModerationCategories(document.RootElement, options); + } + + internal static ModerationCategories DeserializeModerationCategories(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("hate") != true) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool hate = default; + bool hateThreatening = default; + bool harassment = default; + bool harassmentThreatening = default; + bool selfHarm = default; + bool selfHarmIntent = default; + bool selfHarmInstructions = default; + bool sexual = default; + bool sexualMinors = default; + bool violence = default; + bool violenceGraphic = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("hate"u8)) { - writer.WritePropertyName("hate"u8); - writer.WriteBooleanValue(Hate); + hate = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("hate/threatening") != true) + if (property.NameEquals("hate/threatening"u8)) { - writer.WritePropertyName("hate/threatening"u8); - writer.WriteBooleanValue(HateThreatening); + hateThreatening = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("harassment") != true) + if (property.NameEquals("harassment"u8)) { - writer.WritePropertyName("harassment"u8); - writer.WriteBooleanValue(Harassment); + harassment = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("harassment/threatening") != true) + if (property.NameEquals("harassment/threatening"u8)) { - writer.WritePropertyName("harassment/threatening"u8); - writer.WriteBooleanValue(HarassmentThreatening); + harassmentThreatening = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("self-harm") != true) + if (property.NameEquals("self-harm"u8)) { - writer.WritePropertyName("self-harm"u8); - writer.WriteBooleanValue(SelfHarm); + selfHarm = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("self-harm/intent") != true) + if (property.NameEquals("self-harm/intent"u8)) { - writer.WritePropertyName("self-harm/intent"u8); - writer.WriteBooleanValue(SelfHarmIntent); + selfHarmIntent = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("self-harm/instructions") != true) + if (property.NameEquals("self-harm/instructions"u8)) { - writer.WritePropertyName("self-harm/instructions"u8); - writer.WriteBooleanValue(SelfHarmInstructions); + selfHarmInstructions = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("sexual") != true) + if (property.NameEquals("sexual"u8)) { - writer.WritePropertyName("sexual"u8); - writer.WriteBooleanValue(Sexual); + sexual = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("sexual/minors") != true) + if (property.NameEquals("sexual/minors"u8)) { - writer.WritePropertyName("sexual/minors"u8); - writer.WriteBooleanValue(SexualMinors); + sexualMinors = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("violence") != true) + if (property.NameEquals("violence"u8)) { - writer.WritePropertyName("violence"u8); - writer.WriteBooleanValue(Violence); + violence = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("violence/graphic") != true) + if (property.NameEquals("violence/graphic"u8)) { - writer.WritePropertyName("violence/graphic"u8); - writer.WriteBooleanValue(ViolenceGraphic); + violenceGraphic = property.Value.GetBoolean(); + continue; } - if (SerializedAdditionalRawData != null) + if (true) { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - writer.WriteEndObject(); } + serializedAdditionalRawData = rawDataDictionary; + return new ModerationCategories( + hate, + hateThreatening, + harassment, + harassmentThreatening, + selfHarm, + selfHarmIntent, + selfHarmInstructions, + sexual, + sexualMinors, + violence, + violenceGraphic, + serializedAdditionalRawData); + } - ModerationCategories IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModerationCategories)} does not support reading '{format}' format."); - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeModerationCategories(document.RootElement, options); + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ModerationCategories)} does not support writing '{options.Format}' format."); } + } - internal static ModerationCategories DeserializeModerationCategories(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + ModerationCategories IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - bool hate = default; - bool hateThreatening = default; - bool harassment = default; - bool harassmentThreatening = default; - bool selfHarm = default; - bool selfHarmIntent = default; - bool selfHarmInstructions = default; - bool sexual = default; - bool sexualMinors = default; - bool violence = default; - bool violenceGraphic = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("hate"u8)) - { - hate = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("hate/threatening"u8)) - { - hateThreatening = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("harassment"u8)) - { - harassment = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("harassment/threatening"u8)) - { - harassmentThreatening = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("self-harm"u8)) - { - selfHarm = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("self-harm/intent"u8)) - { - selfHarmIntent = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("self-harm/instructions"u8)) - { - selfHarmInstructions = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("sexual"u8)) - { - sexual = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("sexual/minors"u8)) - { - sexualMinors = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("violence"u8)) - { - violence = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("violence/graphic"u8)) - { - violenceGraphic = property.Value.GetBoolean(); - continue; - } - if (true) + switch (format) + { + case "J": { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModerationCategories(document.RootElement, options); } - } - serializedAdditionalRawData = rawDataDictionary; - return new ModerationCategories( - hate, - hateThreatening, - harassment, - harassmentThreatening, - selfHarm, - selfHarmIntent, - selfHarmInstructions, - sexual, - sexualMinors, - violence, - violenceGraphic, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ModerationCategories)} does not support writing '{options.Format}' format."); - } - } - - ModerationCategories IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeModerationCategories(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModerationCategories)} does not support reading '{options.Format}' format."); - } + default: + throw new FormatException($"The model {nameof(ModerationCategories)} does not support reading '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - internal static ModerationCategories FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeModerationCategories(document.RootElement); - } + internal static ModerationCategories FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeModerationCategories(document.RootElement); + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationCategories.cs b/src/Generated/Models/ModerationCategories.cs index 978eaf4e..88ce89cf 100644 --- a/src/Generated/Models/ModerationCategories.cs +++ b/src/Generated/Models/ModerationCategories.cs @@ -5,56 +5,55 @@ using System; using System.Collections.Generic; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationCategories { - public partial class ModerationCategories + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ModerationCategories(bool hate, bool hateThreatening, bool harassment, bool harassmentThreatening, bool selfHarm, bool selfHarmIntent, bool selfHarmInstructions, bool sexual, bool sexualMinors, bool violence, bool violenceGraphic) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ModerationCategories(bool hate, bool hateThreatening, bool harassment, bool harassmentThreatening, bool selfHarm, bool selfHarmIntent, bool selfHarmInstructions, bool sexual, bool sexualMinors, bool violence, bool violenceGraphic) - { - Hate = hate; - HateThreatening = hateThreatening; - Harassment = harassment; - HarassmentThreatening = harassmentThreatening; - SelfHarm = selfHarm; - SelfHarmIntent = selfHarmIntent; - SelfHarmInstructions = selfHarmInstructions; - Sexual = sexual; - SexualMinors = sexualMinors; - Violence = violence; - ViolenceGraphic = violenceGraphic; - } - - internal ModerationCategories(bool hate, bool hateThreatening, bool harassment, bool harassmentThreatening, bool selfHarm, bool selfHarmIntent, bool selfHarmInstructions, bool sexual, bool sexualMinors, bool violence, bool violenceGraphic, IDictionary serializedAdditionalRawData) - { - Hate = hate; - HateThreatening = hateThreatening; - Harassment = harassment; - HarassmentThreatening = harassmentThreatening; - SelfHarm = selfHarm; - SelfHarmIntent = selfHarmIntent; - SelfHarmInstructions = selfHarmInstructions; - Sexual = sexual; - SexualMinors = sexualMinors; - Violence = violence; - ViolenceGraphic = violenceGraphic; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Hate = hate; + HateThreatening = hateThreatening; + Harassment = harassment; + HarassmentThreatening = harassmentThreatening; + SelfHarm = selfHarm; + SelfHarmIntent = selfHarmIntent; + SelfHarmInstructions = selfHarmInstructions; + Sexual = sexual; + SexualMinors = sexualMinors; + Violence = violence; + ViolenceGraphic = violenceGraphic; + } - internal ModerationCategories() - { - } + internal ModerationCategories(bool hate, bool hateThreatening, bool harassment, bool harassmentThreatening, bool selfHarm, bool selfHarmIntent, bool selfHarmInstructions, bool sexual, bool sexualMinors, bool violence, bool violenceGraphic, IDictionary serializedAdditionalRawData) + { + Hate = hate; + HateThreatening = hateThreatening; + Harassment = harassment; + HarassmentThreatening = harassmentThreatening; + SelfHarm = selfHarm; + SelfHarmIntent = selfHarmIntent; + SelfHarmInstructions = selfHarmInstructions; + Sexual = sexual; + SexualMinors = sexualMinors; + Violence = violence; + ViolenceGraphic = violenceGraphic; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public bool Hate { get; } - public bool HateThreatening { get; } - public bool Harassment { get; } - public bool HarassmentThreatening { get; } - public bool SelfHarm { get; } - public bool SelfHarmIntent { get; } - public bool SelfHarmInstructions { get; } - public bool Sexual { get; } - public bool SexualMinors { get; } - public bool Violence { get; } - public bool ViolenceGraphic { get; } + internal ModerationCategories() + { } -} + + public bool Hate { get; } + public bool HateThreatening { get; } + public bool Harassment { get; } + public bool HarassmentThreatening { get; } + public bool SelfHarm { get; } + public bool SelfHarmIntent { get; } + public bool SelfHarmInstructions { get; } + public bool Sexual { get; } + public bool SexualMinors { get; } + public bool Violence { get; } + public bool ViolenceGraphic { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationCategoryScores.Serialization.cs b/src/Generated/Models/ModerationCategoryScores.Serialization.cs index 52df6f3f..97a525c7 100644 --- a/src/Generated/Models/ModerationCategoryScores.Serialization.cs +++ b/src/Generated/Models/ModerationCategoryScores.Serialization.cs @@ -8,248 +8,247 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationCategoryScores : IJsonModel { - public partial class ModerationCategoryScores : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("hate") != true) + { + writer.WritePropertyName("hate"u8); + writer.WriteNumberValue(Hate); + } + if (SerializedAdditionalRawData?.ContainsKey("hate/threatening") != true) + { + writer.WritePropertyName("hate/threatening"u8); + writer.WriteNumberValue(HateThreatening); + } + if (SerializedAdditionalRawData?.ContainsKey("harassment") != true) + { + writer.WritePropertyName("harassment"u8); + writer.WriteNumberValue(Harassment); + } + if (SerializedAdditionalRawData?.ContainsKey("harassment/threatening") != true) + { + writer.WritePropertyName("harassment/threatening"u8); + writer.WriteNumberValue(HarassmentThreatening); + } + if (SerializedAdditionalRawData?.ContainsKey("self-harm") != true) + { + writer.WritePropertyName("self-harm"u8); + writer.WriteNumberValue(SelfHarm); + } + if (SerializedAdditionalRawData?.ContainsKey("self-harm/intent") != true) + { + writer.WritePropertyName("self-harm/intent"u8); + writer.WriteNumberValue(SelfHarmIntent); + } + if (SerializedAdditionalRawData?.ContainsKey("self-harm/instructions") != true) + { + writer.WritePropertyName("self-harm/instructions"u8); + writer.WriteNumberValue(SelfHarmInstructions); + } + if (SerializedAdditionalRawData?.ContainsKey("sexual") != true) + { + writer.WritePropertyName("sexual"u8); + writer.WriteNumberValue(Sexual); + } + if (SerializedAdditionalRawData?.ContainsKey("sexual/minors") != true) + { + writer.WritePropertyName("sexual/minors"u8); + writer.WriteNumberValue(SexualMinors); + } + if (SerializedAdditionalRawData?.ContainsKey("violence") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("violence"u8); + writer.WriteNumberValue(Violence); + } + if (SerializedAdditionalRawData?.ContainsKey("violence/graphic") != true) + { + writer.WritePropertyName("violence/graphic"u8); + writer.WriteNumberValue(ViolenceGraphic); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support writing '{format}' format."); + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif } + } + writer.WriteEndObject(); + } + + ModerationCategoryScores IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModerationCategoryScores(document.RootElement, options); + } + + internal static ModerationCategoryScores DeserializeModerationCategoryScores(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("hate") != true) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + float hate = default; + float hateThreatening = default; + float harassment = default; + float harassmentThreatening = default; + float selfHarm = default; + float selfHarmIntent = default; + float selfHarmInstructions = default; + float sexual = default; + float sexualMinors = default; + float violence = default; + float violenceGraphic = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("hate"u8)) { - writer.WritePropertyName("hate"u8); - writer.WriteNumberValue(Hate); + hate = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("hate/threatening") != true) + if (property.NameEquals("hate/threatening"u8)) { - writer.WritePropertyName("hate/threatening"u8); - writer.WriteNumberValue(HateThreatening); + hateThreatening = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("harassment") != true) + if (property.NameEquals("harassment"u8)) { - writer.WritePropertyName("harassment"u8); - writer.WriteNumberValue(Harassment); + harassment = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("harassment/threatening") != true) + if (property.NameEquals("harassment/threatening"u8)) { - writer.WritePropertyName("harassment/threatening"u8); - writer.WriteNumberValue(HarassmentThreatening); + harassmentThreatening = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("self-harm") != true) + if (property.NameEquals("self-harm"u8)) { - writer.WritePropertyName("self-harm"u8); - writer.WriteNumberValue(SelfHarm); + selfHarm = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("self-harm/intent") != true) + if (property.NameEquals("self-harm/intent"u8)) { - writer.WritePropertyName("self-harm/intent"u8); - writer.WriteNumberValue(SelfHarmIntent); + selfHarmIntent = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("self-harm/instructions") != true) + if (property.NameEquals("self-harm/instructions"u8)) { - writer.WritePropertyName("self-harm/instructions"u8); - writer.WriteNumberValue(SelfHarmInstructions); + selfHarmInstructions = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("sexual") != true) + if (property.NameEquals("sexual"u8)) { - writer.WritePropertyName("sexual"u8); - writer.WriteNumberValue(Sexual); + sexual = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("sexual/minors") != true) + if (property.NameEquals("sexual/minors"u8)) { - writer.WritePropertyName("sexual/minors"u8); - writer.WriteNumberValue(SexualMinors); + sexualMinors = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("violence") != true) + if (property.NameEquals("violence"u8)) { - writer.WritePropertyName("violence"u8); - writer.WriteNumberValue(Violence); + violence = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("violence/graphic") != true) + if (property.NameEquals("violence/graphic"u8)) { - writer.WritePropertyName("violence/graphic"u8); - writer.WriteNumberValue(ViolenceGraphic); + violenceGraphic = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData != null) + if (true) { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - writer.WriteEndObject(); } + serializedAdditionalRawData = rawDataDictionary; + return new ModerationCategoryScores( + hate, + hateThreatening, + harassment, + harassmentThreatening, + selfHarm, + selfHarmIntent, + selfHarmInstructions, + sexual, + sexualMinors, + violence, + violenceGraphic, + serializedAdditionalRawData); + } - ModerationCategoryScores IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support reading '{format}' format."); - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeModerationCategoryScores(document.RootElement, options); + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support writing '{options.Format}' format."); } + } - internal static ModerationCategoryScores DeserializeModerationCategoryScores(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + ModerationCategoryScores IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - float hate = default; - float hateThreatening = default; - float harassment = default; - float harassmentThreatening = default; - float selfHarm = default; - float selfHarmIntent = default; - float selfHarmInstructions = default; - float sexual = default; - float sexualMinors = default; - float violence = default; - float violenceGraphic = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("hate"u8)) - { - hate = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("hate/threatening"u8)) - { - hateThreatening = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("harassment"u8)) - { - harassment = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("harassment/threatening"u8)) - { - harassmentThreatening = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("self-harm"u8)) - { - selfHarm = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("self-harm/intent"u8)) - { - selfHarmIntent = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("self-harm/instructions"u8)) - { - selfHarmInstructions = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("sexual"u8)) - { - sexual = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("sexual/minors"u8)) - { - sexualMinors = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("violence"u8)) - { - violence = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("violence/graphic"u8)) - { - violenceGraphic = property.Value.GetSingle(); - continue; - } - if (true) + switch (format) + { + case "J": { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModerationCategoryScores(document.RootElement, options); } - } - serializedAdditionalRawData = rawDataDictionary; - return new ModerationCategoryScores( - hate, - hateThreatening, - harassment, - harassmentThreatening, - selfHarm, - selfHarmIntent, - selfHarmInstructions, - sexual, - sexualMinors, - violence, - violenceGraphic, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support writing '{options.Format}' format."); - } - } - - ModerationCategoryScores IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeModerationCategoryScores(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support reading '{options.Format}' format."); - } + default: + throw new FormatException($"The model {nameof(ModerationCategoryScores)} does not support reading '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - internal static ModerationCategoryScores FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeModerationCategoryScores(document.RootElement); - } + internal static ModerationCategoryScores FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeModerationCategoryScores(document.RootElement); + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationCategoryScores.cs b/src/Generated/Models/ModerationCategoryScores.cs index a734260c..37917dbf 100644 --- a/src/Generated/Models/ModerationCategoryScores.cs +++ b/src/Generated/Models/ModerationCategoryScores.cs @@ -5,56 +5,55 @@ using System; using System.Collections.Generic; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationCategoryScores { - public partial class ModerationCategoryScores + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ModerationCategoryScores(float hate, float hateThreatening, float harassment, float harassmentThreatening, float selfHarm, float selfHarmIntent, float selfHarmInstructions, float sexual, float sexualMinors, float violence, float violenceGraphic) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ModerationCategoryScores(float hate, float hateThreatening, float harassment, float harassmentThreatening, float selfHarm, float selfHarmIntent, float selfHarmInstructions, float sexual, float sexualMinors, float violence, float violenceGraphic) - { - Hate = hate; - HateThreatening = hateThreatening; - Harassment = harassment; - HarassmentThreatening = harassmentThreatening; - SelfHarm = selfHarm; - SelfHarmIntent = selfHarmIntent; - SelfHarmInstructions = selfHarmInstructions; - Sexual = sexual; - SexualMinors = sexualMinors; - Violence = violence; - ViolenceGraphic = violenceGraphic; - } - - internal ModerationCategoryScores(float hate, float hateThreatening, float harassment, float harassmentThreatening, float selfHarm, float selfHarmIntent, float selfHarmInstructions, float sexual, float sexualMinors, float violence, float violenceGraphic, IDictionary serializedAdditionalRawData) - { - Hate = hate; - HateThreatening = hateThreatening; - Harassment = harassment; - HarassmentThreatening = harassmentThreatening; - SelfHarm = selfHarm; - SelfHarmIntent = selfHarmIntent; - SelfHarmInstructions = selfHarmInstructions; - Sexual = sexual; - SexualMinors = sexualMinors; - Violence = violence; - ViolenceGraphic = violenceGraphic; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Hate = hate; + HateThreatening = hateThreatening; + Harassment = harassment; + HarassmentThreatening = harassmentThreatening; + SelfHarm = selfHarm; + SelfHarmIntent = selfHarmIntent; + SelfHarmInstructions = selfHarmInstructions; + Sexual = sexual; + SexualMinors = sexualMinors; + Violence = violence; + ViolenceGraphic = violenceGraphic; + } - internal ModerationCategoryScores() - { - } + internal ModerationCategoryScores(float hate, float hateThreatening, float harassment, float harassmentThreatening, float selfHarm, float selfHarmIntent, float selfHarmInstructions, float sexual, float sexualMinors, float violence, float violenceGraphic, IDictionary serializedAdditionalRawData) + { + Hate = hate; + HateThreatening = hateThreatening; + Harassment = harassment; + HarassmentThreatening = harassmentThreatening; + SelfHarm = selfHarm; + SelfHarmIntent = selfHarmIntent; + SelfHarmInstructions = selfHarmInstructions; + Sexual = sexual; + SexualMinors = sexualMinors; + Violence = violence; + ViolenceGraphic = violenceGraphic; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public float Hate { get; } - public float HateThreatening { get; } - public float Harassment { get; } - public float HarassmentThreatening { get; } - public float SelfHarm { get; } - public float SelfHarmIntent { get; } - public float SelfHarmInstructions { get; } - public float Sexual { get; } - public float SexualMinors { get; } - public float Violence { get; } - public float ViolenceGraphic { get; } + internal ModerationCategoryScores() + { } -} + + public float Hate { get; } + public float HateThreatening { get; } + public float Harassment { get; } + public float HarassmentThreatening { get; } + public float SelfHarm { get; } + public float SelfHarmIntent { get; } + public float SelfHarmInstructions { get; } + public float Sexual { get; } + public float SexualMinors { get; } + public float Violence { get; } + public float ViolenceGraphic { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationCollection.Serialization.cs b/src/Generated/Models/ModerationCollection.Serialization.cs index cb0f039f..f5e863fe 100644 --- a/src/Generated/Models/ModerationCollection.Serialization.cs +++ b/src/Generated/Models/ModerationCollection.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationCollection : IJsonModel { - public partial class ModerationCollection : IJsonModel + ModerationCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ModerationCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModerationCollection)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeModerationCollection(document.RootElement, options); + throw new FormatException($"The model {nameof(ModerationCollection)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModerationCollection(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ModerationCollection)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - ModerationCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeModerationCollection(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModerationCollection)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ModerationCollection)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ModerationCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ModerationCollection FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeModerationCollection(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModerationCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModerationCollection)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ModerationCollection FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeModerationCollection(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationCollection.cs b/src/Generated/Models/ModerationCollection.cs index c8436d80..3d30a5ce 100644 --- a/src/Generated/Models/ModerationCollection.cs +++ b/src/Generated/Models/ModerationCollection.cs @@ -6,11 +6,10 @@ using System.Collections.ObjectModel; using System.Linq; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationCollection : ReadOnlyCollection { - public partial class ModerationCollection : ReadOnlyCollection - { - public string Id { get; } - public string Model { get; } - } -} + public string Id { get; } + public string Model { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationOptions.Serialization.cs b/src/Generated/Models/ModerationOptions.Serialization.cs index 59157723..ed211114 100644 --- a/src/Generated/Models/ModerationOptions.Serialization.cs +++ b/src/Generated/Models/ModerationOptions.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +internal partial class ModerationOptions : IJsonModel { - internal partial class ModerationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModerationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ModerationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("input") != true) - { - writer.WritePropertyName("input"u8); + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("input") != true) + { + writer.WritePropertyName("input"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(Input); #else - using (JsonDocument document = JsonDocument.Parse(Input)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + using (JsonDocument document = JsonDocument.Parse(Input)) { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.Value.ToString()); + JsonSerializer.Serialize(writer, document.RootElement); } - if (SerializedAdditionalRawData != null) +#endif + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.Value.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ModerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ModerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModerationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeModerationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(ModerationOptions)} does not support reading '{format}' format."); } - internal static ModerationOptions DeserializeModerationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModerationOptions(document.RootElement, options); + } + + internal static ModerationOptions DeserializeModerationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BinaryData input = default; + InternalCreateModerationRequestModel? model = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input"u8)) { - return null; + input = BinaryData.FromString(property.Value.GetRawText()); + continue; } - BinaryData input = default; - InternalCreateModerationRequestModel? model = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("model"u8)) { - if (property.NameEquals("input"u8)) - { - input = BinaryData.FromString(property.Value.GetRawText()); - continue; - } - if (property.NameEquals("model"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - model = new InternalCreateModerationRequestModel(property.Value.GetString()); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + model = new InternalCreateModerationRequestModel(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ModerationOptions(input, model, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ModerationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ModerationOptions(input, model, serializedAdditionalRawData); + } - ModerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeModerationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModerationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ModerationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ModerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ModerationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeModerationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModerationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModerationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ModerationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeModerationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationOptions.cs b/src/Generated/Models/ModerationOptions.cs index e21defe3..80d19993 100644 --- a/src/Generated/Models/ModerationOptions.cs +++ b/src/Generated/Models/ModerationOptions.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +internal partial class ModerationOptions { - internal partial class ModerationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ModerationOptions(BinaryData input, InternalCreateModerationRequestModel? model, IDictionary serializedAdditionalRawData) - { - Input = input; - Model = model; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ModerationOptions(BinaryData input, InternalCreateModerationRequestModel? model, IDictionary serializedAdditionalRawData) + { + Input = input; + Model = model; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationResult.Serialization.cs b/src/Generated/Models/ModerationResult.Serialization.cs index 4e5f4ee2..afabeb88 100644 --- a/src/Generated/Models/ModerationResult.Serialization.cs +++ b/src/Generated/Models/ModerationResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationResult : IJsonModel { - public partial class ModerationResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModerationResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ModerationResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("flagged") != true) - { - writer.WritePropertyName("flagged"u8); - writer.WriteBooleanValue(Flagged); - } - if (SerializedAdditionalRawData?.ContainsKey("categories") != true) - { - writer.WritePropertyName("categories"u8); - writer.WriteObjectValue(Categories, options); - } - if (SerializedAdditionalRawData?.ContainsKey("category_scores") != true) - { - writer.WritePropertyName("category_scores"u8); - writer.WriteObjectValue(CategoryScores, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("flagged") != true) + { + writer.WritePropertyName("flagged"u8); + writer.WriteBooleanValue(Flagged); + } + if (SerializedAdditionalRawData?.ContainsKey("categories") != true) + { + writer.WritePropertyName("categories"u8); + writer.WriteObjectValue(Categories, options); + } + if (SerializedAdditionalRawData?.ContainsKey("category_scores") != true) + { + writer.WritePropertyName("category_scores"u8); + writer.WriteObjectValue(CategoryScores, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ModerationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ModerationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ModerationResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeModerationResult(document.RootElement, options); + throw new FormatException($"The model {nameof(ModerationResult)} does not support reading '{format}' format."); } - internal static ModerationResult DeserializeModerationResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModerationResult(document.RootElement, options); + } + + internal static ModerationResult DeserializeModerationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool flagged = default; + ModerationCategories categories = default; + ModerationCategoryScores categoryScores = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("flagged"u8)) { - return null; + flagged = property.Value.GetBoolean(); + continue; } - bool flagged = default; - ModerationCategories categories = default; - ModerationCategoryScores categoryScores = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("categories"u8)) { - if (property.NameEquals("flagged"u8)) - { - flagged = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("categories"u8)) - { - categories = ModerationCategories.DeserializeModerationCategories(property.Value, options); - continue; - } - if (property.NameEquals("category_scores"u8)) - { - categoryScores = ModerationCategoryScores.DeserializeModerationCategoryScores(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + categories = ModerationCategories.DeserializeModerationCategories(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ModerationResult(flagged, categories, categoryScores, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("category_scores"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ModerationResult)} does not support writing '{options.Format}' format."); + categoryScores = ModerationCategoryScores.DeserializeModerationCategoryScores(property.Value, options); + continue; } - } - - ModerationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeModerationResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ModerationResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ModerationResult(flagged, categories, categoryScores, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ModerationResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeModerationResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ModerationResult)} does not support writing '{options.Format}' format."); } + } + + ModerationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeModerationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModerationResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ModerationResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeModerationResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ModerationResult.cs b/src/Generated/Models/ModerationResult.cs index ae015e2e..91eb5736 100644 --- a/src/Generated/Models/ModerationResult.cs +++ b/src/Generated/Models/ModerationResult.cs @@ -5,35 +5,34 @@ using System; using System.Collections.Generic; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +public partial class ModerationResult { - public partial class ModerationResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ModerationResult(bool flagged, ModerationCategories categories, ModerationCategoryScores categoryScores) + { + Argument.AssertNotNull(categories, nameof(categories)); + Argument.AssertNotNull(categoryScores, nameof(categoryScores)); + + Flagged = flagged; + Categories = categories; + CategoryScores = categoryScores; + } + + internal ModerationResult(bool flagged, ModerationCategories categories, ModerationCategoryScores categoryScores, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ModerationResult(bool flagged, ModerationCategories categories, ModerationCategoryScores categoryScores) - { - Argument.AssertNotNull(categories, nameof(categories)); - Argument.AssertNotNull(categoryScores, nameof(categoryScores)); - - Flagged = flagged; - Categories = categories; - CategoryScores = categoryScores; - } - - internal ModerationResult(bool flagged, ModerationCategories categories, ModerationCategoryScores categoryScores, IDictionary serializedAdditionalRawData) - { - Flagged = flagged; - Categories = categories; - CategoryScores = categoryScores; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal ModerationResult() - { - } - - public bool Flagged { get; } - public ModerationCategories Categories { get; } - public ModerationCategoryScores CategoryScores { get; } + Flagged = flagged; + Categories = categories; + CategoryScores = categoryScores; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal ModerationResult() + { + } + + public bool Flagged { get; } + public ModerationCategories Categories { get; } + public ModerationCategoryScores CategoryScores { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIError.Serialization.cs b/src/Generated/Models/OpenAIError.Serialization.cs index 6bc1f6fc..90a01c86 100644 --- a/src/Generated/Models/OpenAIError.Serialization.cs +++ b/src/Generated/Models/OpenAIError.Serialization.cs @@ -8,183 +8,182 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class OpenAIError : IJsonModel { - internal partial class OpenAIError : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIError)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(OpenAIError)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code") != true) + { + if (Code != null) { - if (Code != null) - { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code); - } - else - { - writer.WriteNull("code"); - } + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) + else { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); + writer.WriteNull("code"); } - if (SerializedAdditionalRawData?.ContainsKey("param") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData?.ContainsKey("param") != true) + { + if (Param != null) { - if (Param != null) - { - writer.WritePropertyName("param"u8); - writer.WriteStringValue(Param); - } - else - { - writer.WriteNull("param"); - } + writer.WritePropertyName("param"u8); + writer.WriteStringValue(Param); } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) + else { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); + writer.WriteNull("param"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - OpenAIError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + OpenAIError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenAIError(document.RootElement, options); + throw new FormatException($"The model {nameof(OpenAIError)} does not support reading '{format}' format."); } - internal static OpenAIError DeserializeOpenAIError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIError(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string code = default; - string message = default; - string param = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static OpenAIError DeserializeOpenAIError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + string param = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) { - if (property.NameEquals("code"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - code = null; - continue; - } - code = property.Value.GetString(); - continue; - } - if (property.NameEquals("message"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - message = property.Value.GetString(); + code = null; continue; } - if (property.NameEquals("param"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - param = null; - continue; - } - param = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("param"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - type = property.Value.GetString(); + param = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + param = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new OpenAIError(code, message, param, type, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(OpenAIError)} does not support writing '{options.Format}' format."); + type = property.Value.GetString(); + continue; } - } - - OpenAIError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeOpenAIError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenAIError)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIError(code, message, param, type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static OpenAIError FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeOpenAIError(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIError)} does not support writing '{options.Format}' format."); } + } + + OpenAIError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIError)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static OpenAIError FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIError(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIError.cs b/src/Generated/Models/OpenAIError.cs index 7b94f06f..1b79d197 100644 --- a/src/Generated/Models/OpenAIError.cs +++ b/src/Generated/Models/OpenAIError.cs @@ -5,38 +5,37 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class OpenAIError { - internal partial class OpenAIError + internal IDictionary SerializedAdditionalRawData { get; set; } + internal OpenAIError(string code, string message, string param, string type) + { + Argument.AssertNotNull(message, nameof(message)); + Argument.AssertNotNull(type, nameof(type)); + + Code = code; + Message = message; + Param = param; + Type = type; + } + + internal OpenAIError(string code, string message, string param, string type, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal OpenAIError(string code, string message, string param, string type) - { - Argument.AssertNotNull(message, nameof(message)); - Argument.AssertNotNull(type, nameof(type)); - - Code = code; - Message = message; - Param = param; - Type = type; - } - - internal OpenAIError(string code, string message, string param, string type, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - Param = param; - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal OpenAIError() - { - } - - public string Code { get; } - public string Message { get; } - public string Param { get; } - public string Type { get; } + Code = code; + Message = message; + Param = param; + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal OpenAIError() + { + } + + public string Code { get; } + public string Message { get; } + public string Param { get; } + public string Type { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIErrorResponse.Serialization.cs b/src/Generated/Models/OpenAIErrorResponse.Serialization.cs index e78630ae..3ccb7468 100644 --- a/src/Generated/Models/OpenAIErrorResponse.Serialization.cs +++ b/src/Generated/Models/OpenAIErrorResponse.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class OpenAIErrorResponse : IJsonModel { - internal partial class OpenAIErrorResponse : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("error") != true) - { - writer.WritePropertyName("error"u8); - writer.WriteObjectValue(Error, options); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support writing '{format}' format."); } - OpenAIErrorResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("error") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenAIErrorResponse(document.RootElement, options); + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); } - - internal static OpenAIErrorResponse DeserializeOpenAIErrorResponse(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - OpenAIError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("error"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - error = OpenAIError.DeserializeOpenAIError(property.Value, options); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new OpenAIErrorResponse(error, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + OpenAIErrorResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support reading '{format}' format."); } - OpenAIErrorResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIErrorResponse(document.RootElement, options); + } + + internal static OpenAIErrorResponse DeserializeOpenAIErrorResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenAIError error = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("error"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeOpenAIErrorResponse(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support reading '{options.Format}' format."); + error = OpenAIError.DeserializeOpenAIError(property.Value, options); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIErrorResponse(error, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static OpenAIErrorResponse FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeOpenAIErrorResponse(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support writing '{options.Format}' format."); } + } + + OpenAIErrorResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIErrorResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIErrorResponse)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static OpenAIErrorResponse FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIErrorResponse(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIErrorResponse.cs b/src/Generated/Models/OpenAIErrorResponse.cs index 764dd385..0443f3b3 100644 --- a/src/Generated/Models/OpenAIErrorResponse.cs +++ b/src/Generated/Models/OpenAIErrorResponse.cs @@ -5,28 +5,27 @@ using System; using System.Collections.Generic; -namespace OpenAI.Internal +namespace OpenAI.Internal; + +internal partial class OpenAIErrorResponse { - internal partial class OpenAIErrorResponse + internal IDictionary SerializedAdditionalRawData { get; set; } + internal OpenAIErrorResponse(OpenAIError error) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal OpenAIErrorResponse(OpenAIError error) - { - Argument.AssertNotNull(error, nameof(error)); - - Error = error; - } + Argument.AssertNotNull(error, nameof(error)); - internal OpenAIErrorResponse(OpenAIError error, IDictionary serializedAdditionalRawData) - { - Error = error; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Error = error; + } - internal OpenAIErrorResponse() - { - } + internal OpenAIErrorResponse(OpenAIError error, IDictionary serializedAdditionalRawData) + { + Error = error; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public OpenAIError Error { get; } + internal OpenAIErrorResponse() + { } -} + + public OpenAIError Error { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIFileInfo.Serialization.cs b/src/Generated/Models/OpenAIFileInfo.Serialization.cs index fcd6544a..19c028c0 100644 --- a/src/Generated/Models/OpenAIFileInfo.Serialization.cs +++ b/src/Generated/Models/OpenAIFileInfo.Serialization.cs @@ -8,224 +8,223 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +public partial class OpenAIFileInfo : IJsonModel { - public partial class OpenAIFileInfo : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + { + if (SizeInBytes != null) { - throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support writing '{format}' format."); + writer.WritePropertyName("bytes"u8); + writer.WriteNumberValue(SizeInBytes.Value); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + else { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WriteNull("bytes"); } - if (SerializedAdditionalRawData?.ContainsKey("bytes") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("filename") != true) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) + { + writer.WritePropertyName("purpose"u8); + writer.WriteStringValue(Purpose.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("status_details") != true && Optional.IsDefined(StatusDetails)) + { + writer.WritePropertyName("status_details"u8); + writer.WriteStringValue(StatusDetails); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (SizeInBytes != null) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WritePropertyName("bytes"u8); - writer.WriteNumberValue(SizeInBytes.Value); + continue; } - else + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - writer.WriteNull("bytes"); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + } + writer.WriteEndObject(); + } + + OpenAIFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIFileInfo(document.RootElement, options); + } + + internal static OpenAIFileInfo DeserializeOpenAIFileInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + int? bytes = default; + DateTimeOffset createdAt = default; + string filename = default; + InternalOpenAIFileObject @object = default; + OpenAIFilePurpose purpose = default; + OpenAIFileStatus status = default; + string statusDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + id = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("filename") != true) + if (property.NameEquals("bytes"u8)) { - writer.WritePropertyName("filename"u8); - writer.WriteStringValue(Filename); + if (property.Value.ValueKind == JsonValueKind.Null) + { + bytes = null; + continue; + } + bytes = property.Value.GetInt32(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + if (property.NameEquals("created_at"u8)) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("purpose") != true) + if (property.NameEquals("filename"u8)) { - writer.WritePropertyName("purpose"u8); - writer.WriteStringValue(Purpose.ToString()); + filename = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + if (property.NameEquals("object"u8)) { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); + @object = new InternalOpenAIFileObject(property.Value.GetString()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("status_details") != true && Optional.IsDefined(StatusDetails)) + if (property.NameEquals("purpose"u8)) { - writer.WritePropertyName("status_details"u8); - writer.WriteStringValue(StatusDetails); + purpose = new OpenAIFilePurpose(property.Value.GetString()); + continue; } - if (SerializedAdditionalRawData != null) + if (property.NameEquals("status"u8)) { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + status = new OpenAIFileStatus(property.Value.GetString()); + continue; } - writer.WriteEndObject(); - } - - OpenAIFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (property.NameEquals("status_details"u8)) { - throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support reading '{format}' format."); + statusDetails = property.Value.GetString(); + continue; } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenAIFileInfo(document.RootElement, options); - } - - internal static OpenAIFileInfo DeserializeOpenAIFileInfo(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) + if (true) { - return null; + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - string id = default; - int? bytes = default; - DateTimeOffset createdAt = default; - string filename = default; - InternalOpenAIFileObject @object = default; - OpenAIFilePurpose purpose = default; - OpenAIFileStatus status = default; - string statusDetails = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("bytes"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - bytes = null; - continue; - } - bytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("filename"u8)) - { - filename = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalOpenAIFileObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("purpose"u8)) - { - purpose = new OpenAIFilePurpose(property.Value.GetString()); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new OpenAIFileStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("status_details"u8)) - { - statusDetails = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new OpenAIFileInfo( - id, - bytes, - createdAt, - filename, - @object, - purpose, - status, - statusDetails, - serializedAdditionalRawData); } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIFileInfo( + id, + bytes, + createdAt, + filename, + @object, + purpose, + status, + statusDetails, + serializedAdditionalRawData); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - OpenAIFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeOpenAIFileInfo(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + OpenAIFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static OpenAIFileInfo FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeOpenAIFileInfo(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIFileInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIFileInfo)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static OpenAIFileInfo FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIFileInfo(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIFileInfo.cs b/src/Generated/Models/OpenAIFileInfo.cs index 447da57d..19a765f7 100644 --- a/src/Generated/Models/OpenAIFileInfo.cs +++ b/src/Generated/Models/OpenAIFileInfo.cs @@ -5,45 +5,44 @@ using System; using System.Collections.Generic; -namespace OpenAI.Files +namespace OpenAI.Files; + +public partial class OpenAIFileInfo { - public partial class OpenAIFileInfo + internal IDictionary SerializedAdditionalRawData { get; set; } + internal OpenAIFileInfo(string id, int? sizeInBytes, DateTimeOffset createdAt, string filename, OpenAIFilePurpose purpose, OpenAIFileStatus status) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal OpenAIFileInfo(string id, int? sizeInBytes, DateTimeOffset createdAt, string filename, OpenAIFilePurpose purpose, OpenAIFileStatus status) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(filename, nameof(filename)); - - Id = id; - SizeInBytes = sizeInBytes; - CreatedAt = createdAt; - Filename = filename; - Purpose = purpose; - Status = status; - } - - internal OpenAIFileInfo(string id, int? sizeInBytes, DateTimeOffset createdAt, string filename, InternalOpenAIFileObject @object, OpenAIFilePurpose purpose, OpenAIFileStatus status, string statusDetails, IDictionary serializedAdditionalRawData) - { - Id = id; - SizeInBytes = sizeInBytes; - CreatedAt = createdAt; - Filename = filename; - Object = @object; - Purpose = purpose; - Status = status; - StatusDetails = statusDetails; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal OpenAIFileInfo() - { - } - - public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public string Filename { get; } - - public OpenAIFilePurpose Purpose { get; } + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(filename, nameof(filename)); + + Id = id; + SizeInBytes = sizeInBytes; + CreatedAt = createdAt; + Filename = filename; + Purpose = purpose; + Status = status; } -} + + internal OpenAIFileInfo(string id, int? sizeInBytes, DateTimeOffset createdAt, string filename, InternalOpenAIFileObject @object, OpenAIFilePurpose purpose, OpenAIFileStatus status, string statusDetails, IDictionary serializedAdditionalRawData) + { + Id = id; + SizeInBytes = sizeInBytes; + CreatedAt = createdAt; + Filename = filename; + Object = @object; + Purpose = purpose; + Status = status; + StatusDetails = statusDetails; + SerializedAdditionalRawData = serializedAdditionalRawData; + } + + internal OpenAIFileInfo() + { + } + + public string Id { get; } + public DateTimeOffset CreatedAt { get; } + public string Filename { get; } + + public OpenAIFilePurpose Purpose { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIFileInfoCollection.Serialization.cs b/src/Generated/Models/OpenAIFileInfoCollection.Serialization.cs index 5cd5d039..04536024 100644 --- a/src/Generated/Models/OpenAIFileInfoCollection.Serialization.cs +++ b/src/Generated/Models/OpenAIFileInfoCollection.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Files +namespace OpenAI.Files; + +public partial class OpenAIFileInfoCollection : IJsonModel { - public partial class OpenAIFileInfoCollection : IJsonModel + OpenAIFileInfoCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - OpenAIFileInfoCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIFileInfoCollection)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenAIFileInfoCollection(document.RootElement, options); + throw new FormatException($"The model {nameof(OpenAIFileInfoCollection)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIFileInfoCollection(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(OpenAIFileInfoCollection)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - OpenAIFileInfoCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeOpenAIFileInfoCollection(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenAIFileInfoCollection)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIFileInfoCollection)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + OpenAIFileInfoCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static OpenAIFileInfoCollection FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeOpenAIFileInfoCollection(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIFileInfoCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIFileInfoCollection)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static OpenAIFileInfoCollection FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIFileInfoCollection(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIFileInfoCollection.cs b/src/Generated/Models/OpenAIFileInfoCollection.cs index c1887f23..f6c84af6 100644 --- a/src/Generated/Models/OpenAIFileInfoCollection.cs +++ b/src/Generated/Models/OpenAIFileInfoCollection.cs @@ -6,9 +6,8 @@ using System.Collections.ObjectModel; using System.Linq; -namespace OpenAI.Files +namespace OpenAI.Files; + +public partial class OpenAIFileInfoCollection : ReadOnlyCollection { - public partial class OpenAIFileInfoCollection : ReadOnlyCollection - { - } -} +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIFilePurpose.cs b/src/Generated/Models/OpenAIFilePurpose.cs index 71c6cfbf..659f7249 100644 --- a/src/Generated/Models/OpenAIFilePurpose.cs +++ b/src/Generated/Models/OpenAIFilePurpose.cs @@ -5,42 +5,41 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +public readonly partial struct OpenAIFilePurpose : IEquatable { - public readonly partial struct OpenAIFilePurpose : IEquatable + private readonly string _value; + + public OpenAIFilePurpose(string value) { - private readonly string _value; - - public OpenAIFilePurpose(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AssistantsValue = "assistants"; - private const string AssistantsOutputValue = "assistants_output"; - private const string BatchValue = "batch"; - private const string BatchOutputValue = "batch_output"; - private const string FineTuneValue = "fine-tune"; - private const string FineTuneResultsValue = "fine-tune-results"; - private const string VisionValue = "vision"; - - public static OpenAIFilePurpose Assistants { get; } = new OpenAIFilePurpose(AssistantsValue); - public static OpenAIFilePurpose AssistantsOutput { get; } = new OpenAIFilePurpose(AssistantsOutputValue); - public static OpenAIFilePurpose Batch { get; } = new OpenAIFilePurpose(BatchValue); - public static OpenAIFilePurpose BatchOutput { get; } = new OpenAIFilePurpose(BatchOutputValue); - public static OpenAIFilePurpose FineTune { get; } = new OpenAIFilePurpose(FineTuneValue); - public static OpenAIFilePurpose FineTuneResults { get; } = new OpenAIFilePurpose(FineTuneResultsValue); - public static OpenAIFilePurpose Vision { get; } = new OpenAIFilePurpose(VisionValue); - public static bool operator ==(OpenAIFilePurpose left, OpenAIFilePurpose right) => left.Equals(right); - public static bool operator !=(OpenAIFilePurpose left, OpenAIFilePurpose right) => !left.Equals(right); - public static implicit operator OpenAIFilePurpose(string value) => new OpenAIFilePurpose(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIFilePurpose other && Equals(other); - public bool Equals(OpenAIFilePurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AssistantsValue = "assistants"; + private const string AssistantsOutputValue = "assistants_output"; + private const string BatchValue = "batch"; + private const string BatchOutputValue = "batch_output"; + private const string FineTuneValue = "fine-tune"; + private const string FineTuneResultsValue = "fine-tune-results"; + private const string VisionValue = "vision"; + + public static OpenAIFilePurpose Assistants { get; } = new OpenAIFilePurpose(AssistantsValue); + public static OpenAIFilePurpose AssistantsOutput { get; } = new OpenAIFilePurpose(AssistantsOutputValue); + public static OpenAIFilePurpose Batch { get; } = new OpenAIFilePurpose(BatchValue); + public static OpenAIFilePurpose BatchOutput { get; } = new OpenAIFilePurpose(BatchOutputValue); + public static OpenAIFilePurpose FineTune { get; } = new OpenAIFilePurpose(FineTuneValue); + public static OpenAIFilePurpose FineTuneResults { get; } = new OpenAIFilePurpose(FineTuneResultsValue); + public static OpenAIFilePurpose Vision { get; } = new OpenAIFilePurpose(VisionValue); + public static bool operator ==(OpenAIFilePurpose left, OpenAIFilePurpose right) => left.Equals(right); + public static bool operator !=(OpenAIFilePurpose left, OpenAIFilePurpose right) => !left.Equals(right); + public static implicit operator OpenAIFilePurpose(string value) => new OpenAIFilePurpose(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIFilePurpose other && Equals(other); + public bool Equals(OpenAIFilePurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIFileStatus.cs b/src/Generated/Models/OpenAIFileStatus.cs index 9176c861..78280895 100644 --- a/src/Generated/Models/OpenAIFileStatus.cs +++ b/src/Generated/Models/OpenAIFileStatus.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Files +namespace OpenAI.Files; + +public readonly partial struct OpenAIFileStatus : IEquatable { - public readonly partial struct OpenAIFileStatus : IEquatable + private readonly string _value; + + public OpenAIFileStatus(string value) { - private readonly string _value; - - public OpenAIFileStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string UploadedValue = "uploaded"; - private const string ProcessedValue = "processed"; - private const string ErrorValue = "error"; - - public static OpenAIFileStatus Uploaded { get; } = new OpenAIFileStatus(UploadedValue); - public static OpenAIFileStatus Processed { get; } = new OpenAIFileStatus(ProcessedValue); - public static OpenAIFileStatus Error { get; } = new OpenAIFileStatus(ErrorValue); - public static bool operator ==(OpenAIFileStatus left, OpenAIFileStatus right) => left.Equals(right); - public static bool operator !=(OpenAIFileStatus left, OpenAIFileStatus right) => !left.Equals(right); - public static implicit operator OpenAIFileStatus(string value) => new OpenAIFileStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIFileStatus other && Equals(other); - public bool Equals(OpenAIFileStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string UploadedValue = "uploaded"; + private const string ProcessedValue = "processed"; + private const string ErrorValue = "error"; + + public static OpenAIFileStatus Uploaded { get; } = new OpenAIFileStatus(UploadedValue); + public static OpenAIFileStatus Processed { get; } = new OpenAIFileStatus(ProcessedValue); + public static OpenAIFileStatus Error { get; } = new OpenAIFileStatus(ErrorValue); + public static bool operator ==(OpenAIFileStatus left, OpenAIFileStatus right) => left.Equals(right); + public static bool operator !=(OpenAIFileStatus left, OpenAIFileStatus right) => !left.Equals(right); + public static implicit operator OpenAIFileStatus(string value) => new OpenAIFileStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIFileStatus other && Equals(other); + public bool Equals(OpenAIFileStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIModelInfo.Serialization.cs b/src/Generated/Models/OpenAIModelInfo.Serialization.cs index 575c7e96..f884e4f4 100644 --- a/src/Generated/Models/OpenAIModelInfo.Serialization.cs +++ b/src/Generated/Models/OpenAIModelInfo.Serialization.cs @@ -8,159 +8,158 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Models +namespace OpenAI.Models; + +public partial class OpenAIModelInfo : IJsonModel { - public partial class OpenAIModelInfo : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("created") != true) - { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(CreatedAt, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("owned_by") != true) - { - writer.WritePropertyName("owned_by"u8); - writer.WriteStringValue(OwnedBy); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("created") != true) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("owned_by") != true) + { + writer.WritePropertyName("owned_by"u8); + writer.WriteStringValue(OwnedBy); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - OpenAIModelInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + OpenAIModelInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenAIModelInfo(document.RootElement, options); + throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support reading '{format}' format."); } - internal static OpenAIModelInfo DeserializeOpenAIModelInfo(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIModelInfo(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static OpenAIModelInfo DeserializeOpenAIModelInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + DateTimeOffset created = default; + InternalModelObject @object = default; + string ownedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - DateTimeOffset created = default; - InternalModelObject @object = default; - string ownedBy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("created"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("created"u8)) - { - created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalModelObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("owned_by"u8)) - { - ownedBy = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new OpenAIModelInfo(id, created, @object, ownedBy, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support writing '{options.Format}' format."); + @object = new InternalModelObject(property.Value.GetString()); + continue; } - } - - OpenAIModelInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("owned_by"u8)) + { + ownedBy = property.Value.GetString(); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeOpenAIModelInfo(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new OpenAIModelInfo(id, created, @object, ownedBy, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static OpenAIModelInfo FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeOpenAIModelInfo(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support writing '{options.Format}' format."); } + } + + OpenAIModelInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIModelInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIModelInfo)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static OpenAIModelInfo FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIModelInfo(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIModelInfo.cs b/src/Generated/Models/OpenAIModelInfo.cs index c838e75a..9adae540 100644 --- a/src/Generated/Models/OpenAIModelInfo.cs +++ b/src/Generated/Models/OpenAIModelInfo.cs @@ -5,36 +5,35 @@ using System; using System.Collections.Generic; -namespace OpenAI.Models +namespace OpenAI.Models; + +public partial class OpenAIModelInfo { - public partial class OpenAIModelInfo + internal IDictionary SerializedAdditionalRawData { get; set; } + internal OpenAIModelInfo(string id, DateTimeOffset createdAt, string ownedBy) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(ownedBy, nameof(ownedBy)); + + Id = id; + CreatedAt = createdAt; + OwnedBy = ownedBy; + } + + internal OpenAIModelInfo(string id, DateTimeOffset createdAt, InternalModelObject @object, string ownedBy, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal OpenAIModelInfo(string id, DateTimeOffset createdAt, string ownedBy) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(ownedBy, nameof(ownedBy)); - - Id = id; - CreatedAt = createdAt; - OwnedBy = ownedBy; - } - - internal OpenAIModelInfo(string id, DateTimeOffset createdAt, InternalModelObject @object, string ownedBy, IDictionary serializedAdditionalRawData) - { - Id = id; - CreatedAt = createdAt; - Object = @object; - OwnedBy = ownedBy; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal OpenAIModelInfo() - { - } - - public string Id { get; } - - public string OwnedBy { get; } + Id = id; + CreatedAt = createdAt; + Object = @object; + OwnedBy = ownedBy; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal OpenAIModelInfo() + { + } + + public string Id { get; } + + public string OwnedBy { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIModelInfoCollection.Serialization.cs b/src/Generated/Models/OpenAIModelInfoCollection.Serialization.cs index f9790a97..285183c3 100644 --- a/src/Generated/Models/OpenAIModelInfoCollection.Serialization.cs +++ b/src/Generated/Models/OpenAIModelInfoCollection.Serialization.cs @@ -7,62 +7,61 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Models +namespace OpenAI.Models; + +public partial class OpenAIModelInfoCollection : IJsonModel { - public partial class OpenAIModelInfoCollection : IJsonModel + OpenAIModelInfoCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - OpenAIModelInfoCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(OpenAIModelInfoCollection)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeOpenAIModelInfoCollection(document.RootElement, options); + throw new FormatException($"The model {nameof(OpenAIModelInfoCollection)} does not support reading '{format}' format."); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAIModelInfoCollection(document.RootElement, options); + } - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(OpenAIModelInfoCollection)} does not support writing '{options.Format}' format."); - } - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - OpenAIModelInfoCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeOpenAIModelInfoCollection(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(OpenAIModelInfoCollection)} does not support reading '{options.Format}' format."); - } + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OpenAIModelInfoCollection)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + OpenAIModelInfoCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static OpenAIModelInfoCollection FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeOpenAIModelInfoCollection(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOpenAIModelInfoCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAIModelInfoCollection)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static OpenAIModelInfoCollection FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOpenAIModelInfoCollection(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/OpenAIModelInfoCollection.cs b/src/Generated/Models/OpenAIModelInfoCollection.cs index f917c20d..505f2e66 100644 --- a/src/Generated/Models/OpenAIModelInfoCollection.cs +++ b/src/Generated/Models/OpenAIModelInfoCollection.cs @@ -6,9 +6,8 @@ using System.Collections.ObjectModel; using System.Linq; -namespace OpenAI.Models +namespace OpenAI.Models; + +public partial class OpenAIModelInfoCollection : ReadOnlyCollection { - public partial class OpenAIModelInfoCollection : ReadOnlyCollection - { - } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunCollectionOrder.cs b/src/Generated/Models/RunCollectionOrder.cs index ee88afce..8d6bf7e8 100644 --- a/src/Generated/Models/RunCollectionOrder.cs +++ b/src/Generated/Models/RunCollectionOrder.cs @@ -5,29 +5,28 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunCollectionOrder : IEquatable { - public readonly partial struct RunCollectionOrder : IEquatable + private readonly string _value; + + public RunCollectionOrder(string value) { - private readonly string _value; - - public RunCollectionOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AscendingValue = "asc"; - private const string DescendingValue = "desc"; - public static bool operator ==(RunCollectionOrder left, RunCollectionOrder right) => left.Equals(right); - public static bool operator !=(RunCollectionOrder left, RunCollectionOrder right) => !left.Equals(right); - public static implicit operator RunCollectionOrder(string value) => new RunCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunCollectionOrder other && Equals(other); - public bool Equals(RunCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AscendingValue = "asc"; + private const string DescendingValue = "desc"; + public static bool operator ==(RunCollectionOrder left, RunCollectionOrder right) => left.Equals(right); + public static bool operator !=(RunCollectionOrder left, RunCollectionOrder right) => !left.Equals(right); + public static implicit operator RunCollectionOrder(string value) => new RunCollectionOrder(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunCollectionOrder other && Equals(other); + public bool Equals(RunCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunCreationOptions.Serialization.cs b/src/Generated/Models/RunCreationOptions.Serialization.cs index 2c0dc45c..b9f78310 100644 --- a/src/Generated/Models/RunCreationOptions.Serialization.cs +++ b/src/Generated/Models/RunCreationOptions.Serialization.cs @@ -8,508 +8,507 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunCreationOptions : IJsonModel { - public partial class RunCreationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunCreationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + { + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(ModelOverride)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (ModelOverride != null) { - throw new FormatException($"The model {nameof(RunCreationOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("model"u8); + writer.WriteStringValue(ModelOverride); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + else { - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); + writer.WriteNull("model"); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true && Optional.IsDefined(ModelOverride)) + } + if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(InstructionsOverride)) + { + if (InstructionsOverride != null) { - if (ModelOverride != null) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(ModelOverride); - } - else - { - writer.WriteNull("model"); - } + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(InstructionsOverride); } - if (SerializedAdditionalRawData?.ContainsKey("instructions") != true && Optional.IsDefined(InstructionsOverride)) + else { - if (InstructionsOverride != null) - { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(InstructionsOverride); - } - else - { - writer.WriteNull("instructions"); - } + writer.WriteNull("instructions"); } - if (SerializedAdditionalRawData?.ContainsKey("additional_instructions") != true && Optional.IsDefined(AdditionalInstructions)) + } + if (SerializedAdditionalRawData?.ContainsKey("additional_instructions") != true && Optional.IsDefined(AdditionalInstructions)) + { + if (AdditionalInstructions != null) { - if (AdditionalInstructions != null) - { - writer.WritePropertyName("additional_instructions"u8); - writer.WriteStringValue(AdditionalInstructions); - } - else - { - writer.WriteNull("additional_instructions"); - } + writer.WritePropertyName("additional_instructions"u8); + writer.WriteStringValue(AdditionalInstructions); } - if (SerializedAdditionalRawData?.ContainsKey("additional_messages") != true && Optional.IsCollectionDefined(InternalMessages)) + else { - if (InternalMessages != null) - { - writer.WritePropertyName("additional_messages"u8); - writer.WriteStartArray(); - foreach (var item in InternalMessages) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("additional_messages"); - } + writer.WriteNull("additional_instructions"); } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(ToolsOverride)) + } + if (SerializedAdditionalRawData?.ContainsKey("additional_messages") != true && Optional.IsCollectionDefined(InternalMessages)) + { + if (InternalMessages != null) { - if (ToolsOverride != null) - { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in ToolsOverride) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else + writer.WritePropertyName("additional_messages"u8); + writer.WriteStartArray(); + foreach (var item in InternalMessages) { - writer.WriteNull("tools"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + else { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WriteNull("additional_messages"); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true && Optional.IsCollectionDefined(ToolsOverride)) + { + if (ToolsOverride != null) { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in ToolsOverride) { - writer.WriteNull("temperature"); + writer.WriteObjectValue(item, options); } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + else { - if (NucleusSamplingFactor != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(NucleusSamplingFactor.Value); - } - else - { - writer.WriteNull("top_p"); - } + writer.WriteNull("tools"); } - if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (Stream != null) - { - writer.WritePropertyName("stream"u8); - writer.WriteBooleanValue(Stream.Value); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("stream"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("max_prompt_tokens") != true && Optional.IsDefined(MaxPromptTokens)) + else { - if (MaxPromptTokens != null) - { - writer.WritePropertyName("max_prompt_tokens"u8); - writer.WriteNumberValue(MaxPromptTokens.Value); - } - else - { - writer.WriteNull("max_prompt_tokens"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true && Optional.IsDefined(MaxCompletionTokens)) + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + if (Temperature != null) { - if (MaxCompletionTokens != null) - { - writer.WritePropertyName("max_completion_tokens"u8); - writer.WriteNumberValue(MaxCompletionTokens.Value); - } - else - { - writer.WriteNull("max_completion_tokens"); - } + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); } - if (SerializedAdditionalRawData?.ContainsKey("truncation_strategy") != true && Optional.IsDefined(TruncationStrategy)) + else { - if (TruncationStrategy != null) - { - writer.WritePropertyName("truncation_strategy"u8); - writer.WriteObjectValue(TruncationStrategy, options); - } - else - { - writer.WriteNull("truncation_strategy"); - } + writer.WriteNull("temperature"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true && Optional.IsDefined(ToolConstraint)) + } + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + { + if (NucleusSamplingFactor != null) { - if (ToolConstraint != null) - { - writer.WritePropertyName("tool_choice"u8); - SerializeToolConstraint(writer, options); - } - else - { - writer.WriteNull("tool_choice"); - } + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(NucleusSamplingFactor.Value); + } + else + { + writer.WriteNull("top_p"); } - if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCallsEnabled)) + } + if (SerializedAdditionalRawData?.ContainsKey("stream") != true && Optional.IsDefined(Stream)) + { + if (Stream != null) { - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + else { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteObjectValue(ResponseFormat, options); - } - else - { - writer.WriteNull("response_format"); - } + writer.WriteNull("stream"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("max_prompt_tokens") != true && Optional.IsDefined(MaxPromptTokens)) + { + if (MaxPromptTokens != null) + { + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true && Optional.IsDefined(MaxCompletionTokens)) + { + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("truncation_strategy") != true && Optional.IsDefined(TruncationStrategy)) + { + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true && Optional.IsDefined(ToolConstraint)) + { + if (ToolConstraint != null) + { + writer.WritePropertyName("tool_choice"u8); + SerializeToolConstraint(writer, options); + } + else + { + writer.WriteNull("tool_choice"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true && Optional.IsDefined(ParallelToolCallsEnabled)) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); + writer.WriteObjectValue(ResponseFormat, options); + } + else + { + writer.WriteNull("response_format"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunCreationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunCreationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(RunCreationOptions)} does not support reading '{format}' format."); } - internal static RunCreationOptions DeserializeRunCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunCreationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string assistantId = default; - string model = default; - string instructions = default; - string additionalInstructions = default; - IList additionalMessages = default; - IList tools = default; - IDictionary metadata = default; - float? temperature = default; - float? topP = default; - bool? stream = default; - int? maxPromptTokens = default; - int? maxCompletionTokens = default; - RunTruncationStrategy truncationStrategy = default; - ToolConstraint toolChoice = default; - bool? parallelToolCalls = default; - AssistantResponseFormat responseFormat = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("assistant_id"u8)) + internal static RunCreationOptions DeserializeRunCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string assistantId = default; + string model = default; + string instructions = default; + string additionalInstructions = default; + IList additionalMessages = default; + IList tools = default; + IDictionary metadata = default; + float? temperature = default; + float? topP = default; + bool? stream = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + RunTruncationStrategy truncationStrategy = default; + ToolConstraint toolChoice = default; + bool? parallelToolCalls = default; + AssistantResponseFormat responseFormat = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("model"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - assistantId = property.Value.GetString(); + model = null; continue; } - if (property.NameEquals("model"u8)) + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - model = null; - continue; - } - model = property.Value.GetString(); + instructions = null; continue; } - if (property.NameEquals("instructions"u8)) + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("additional_instructions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - instructions = null; - continue; - } - instructions = property.Value.GetString(); + additionalInstructions = null; continue; } - if (property.NameEquals("additional_instructions"u8)) + additionalInstructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("additional_messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - additionalInstructions = null; - continue; - } - additionalInstructions = property.Value.GetString(); continue; } - if (property.NameEquals("additional_messages"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageCreationOptions.DeserializeMessageCreationOptions(item, options)); - } - additionalMessages = array; - continue; + array.Add(MessageCreationOptions.DeserializeMessageCreationOptions(item, options)); } - if (property.NameEquals("tools"u8)) + additionalMessages = array; + continue; + } + if (property.NameEquals("tools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; continue; } - if (property.NameEquals("metadata"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); } - if (property.NameEquals("temperature"u8)) + tools = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); continue; } - if (property.NameEquals("top_p"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); - continue; + dictionary.Add(property0.Name, property0.Value.GetString()); } - if (property.NameEquals("stream"u8)) + metadata = dictionary; + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - stream = null; - continue; - } - stream = property.Value.GetBoolean(); + temperature = null; continue; } - if (property.NameEquals("max_prompt_tokens"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxPromptTokens = null; - continue; - } - maxPromptTokens = property.Value.GetInt32(); + topP = null; continue; } - if (property.NameEquals("max_completion_tokens"u8)) + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxCompletionTokens = null; - continue; - } - maxCompletionTokens = property.Value.GetInt32(); + stream = null; continue; } - if (property.NameEquals("truncation_strategy"u8)) + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - truncationStrategy = null; - continue; - } - truncationStrategy = RunTruncationStrategy.DeserializeRunTruncationStrategy(property.Value, options); + maxPromptTokens = null; continue; } - if (property.NameEquals("tool_choice"u8)) + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolChoice = null; - continue; - } - toolChoice = Assistants.ToolConstraint.DeserializeToolConstraint(property.Value, options); + maxCompletionTokens = null; continue; } - if (property.NameEquals("parallel_tool_calls"u8)) + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - parallelToolCalls = property.Value.GetBoolean(); + truncationStrategy = null; continue; } - if (property.NameEquals("response_format"u8)) + truncationStrategy = RunTruncationStrategy.DeserializeRunTruncationStrategy(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + toolChoice = null; continue; } - if (true) + toolChoice = Assistants.ToolConstraint.DeserializeToolConstraint(property.Value, options); + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + continue; } + parallelToolCalls = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunCreationOptions( - assistantId, - model, - instructions, - additionalInstructions, - additionalMessages ?? new ChangeTrackingList(), - tools ?? new ChangeTrackingList(), - metadata ?? new ChangeTrackingDictionary(), - temperature, - topP, - stream, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - parallelToolCalls, - responseFormat, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("response_format"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunCreationOptions)} does not support writing '{options.Format}' format."); + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + continue; } - } - - RunCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunCreationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunCreationOptions)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunCreationOptions( + assistantId, + model, + instructions, + additionalInstructions, + additionalMessages ?? new ChangeTrackingList(), + tools ?? new ChangeTrackingList(), + metadata ?? new ChangeTrackingDictionary(), + temperature, + topP, + stream, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + parallelToolCalls, + responseFormat, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunCreationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunCreationOptions(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunCreationOptions)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + RunCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunCreationOptions)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunCreationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunCreationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/RunCreationOptions.cs b/src/Generated/Models/RunCreationOptions.cs index 9e0d88fa..5260890e 100644 --- a/src/Generated/Models/RunCreationOptions.cs +++ b/src/Generated/Models/RunCreationOptions.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunCreationOptions { - public partial class RunCreationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunCreationOptions(string assistantId, string modelOverride, string instructionsOverride, string additionalInstructions, IList internalMessages, IList toolsOverride, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) - { - AssistantId = assistantId; - ModelOverride = modelOverride; - InstructionsOverride = instructionsOverride; - AdditionalInstructions = additionalInstructions; - InternalMessages = internalMessages; - ToolsOverride = toolsOverride; - Metadata = metadata; - Temperature = temperature; - NucleusSamplingFactor = nucleusSamplingFactor; - Stream = stream; - MaxPromptTokens = maxPromptTokens; - MaxCompletionTokens = maxCompletionTokens; - TruncationStrategy = truncationStrategy; - ToolConstraint = toolConstraint; - ParallelToolCallsEnabled = parallelToolCallsEnabled; - ResponseFormat = responseFormat; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal RunCreationOptions(string assistantId, string modelOverride, string instructionsOverride, string additionalInstructions, IList internalMessages, IList toolsOverride, IDictionary metadata, float? temperature, float? nucleusSamplingFactor, bool? stream, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + { + AssistantId = assistantId; + ModelOverride = modelOverride; + InstructionsOverride = instructionsOverride; + AdditionalInstructions = additionalInstructions; + InternalMessages = internalMessages; + ToolsOverride = toolsOverride; + Metadata = metadata; + Temperature = temperature; + NucleusSamplingFactor = nucleusSamplingFactor; + Stream = stream; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolConstraint = toolConstraint; + ParallelToolCallsEnabled = parallelToolCallsEnabled; + ResponseFormat = responseFormat; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunError.Serialization.cs b/src/Generated/Models/RunError.Serialization.cs index df0a592e..19aec576 100644 --- a/src/Generated/Models/RunError.Serialization.cs +++ b/src/Generated/Models/RunError.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunError : IJsonModel { - public partial class RunError : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunError)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunError)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code") != true) - { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) - { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code") != true) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunError(document.RootElement, options); + throw new FormatException($"The model {nameof(RunError)} does not support reading '{format}' format."); } - internal static RunError DeserializeRunError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunError(document.RootElement, options); + } + + internal static RunError DeserializeRunError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunErrorCode code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) { - return null; + code = new RunErrorCode(property.Value.GetString()); + continue; } - RunErrorCode code = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("message"u8)) { - if (property.NameEquals("code"u8)) - { - code = new RunErrorCode(property.Value.GetString()); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + message = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunError(code, message, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunError)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunError(code, message, serializedAdditionalRawData); + } - RunError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunError)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunError)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + RunError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunError FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunError(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunError)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunError FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunError(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunError.cs b/src/Generated/Models/RunError.cs index 8404fbbe..e74dd6b6 100644 --- a/src/Generated/Models/RunError.cs +++ b/src/Generated/Models/RunError.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunError { - public partial class RunError + internal IDictionary SerializedAdditionalRawData { get; set; } + internal RunError(RunErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + } + + internal RunError(RunErrorCode code, string message, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunError(RunErrorCode code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - } - - internal RunError(RunErrorCode code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal RunError() - { - } - - public RunErrorCode Code { get; } - public string Message { get; } + Code = code; + Message = message; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal RunError() + { + } + + public RunErrorCode Code { get; } + public string Message { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunErrorCode.cs b/src/Generated/Models/RunErrorCode.cs index 815942d5..339afdb8 100644 --- a/src/Generated/Models/RunErrorCode.cs +++ b/src/Generated/Models/RunErrorCode.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunErrorCode : IEquatable { - public readonly partial struct RunErrorCode : IEquatable + private readonly string _value; + + public RunErrorCode(string value) { - private readonly string _value; - - public RunErrorCode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ServerErrorValue = "server_error"; - private const string RateLimitExceededValue = "rate_limit_exceeded"; - private const string InvalidPromptValue = "invalid_prompt"; - - public static RunErrorCode ServerError { get; } = new RunErrorCode(ServerErrorValue); - public static RunErrorCode RateLimitExceeded { get; } = new RunErrorCode(RateLimitExceededValue); - public static RunErrorCode InvalidPrompt { get; } = new RunErrorCode(InvalidPromptValue); - public static bool operator ==(RunErrorCode left, RunErrorCode right) => left.Equals(right); - public static bool operator !=(RunErrorCode left, RunErrorCode right) => !left.Equals(right); - public static implicit operator RunErrorCode(string value) => new RunErrorCode(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunErrorCode other && Equals(other); - public bool Equals(RunErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string ServerErrorValue = "server_error"; + private const string RateLimitExceededValue = "rate_limit_exceeded"; + private const string InvalidPromptValue = "invalid_prompt"; + + public static RunErrorCode ServerError { get; } = new RunErrorCode(ServerErrorValue); + public static RunErrorCode RateLimitExceeded { get; } = new RunErrorCode(RateLimitExceededValue); + public static RunErrorCode InvalidPrompt { get; } = new RunErrorCode(InvalidPromptValue); + public static bool operator ==(RunErrorCode left, RunErrorCode right) => left.Equals(right); + public static bool operator !=(RunErrorCode left, RunErrorCode right) => !left.Equals(right); + public static implicit operator RunErrorCode(string value) => new RunErrorCode(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunErrorCode other && Equals(other); + public bool Equals(RunErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunIncompleteDetails.Serialization.cs b/src/Generated/Models/RunIncompleteDetails.Serialization.cs index 097376a1..9a3cc1b8 100644 --- a/src/Generated/Models/RunIncompleteDetails.Serialization.cs +++ b/src/Generated/Models/RunIncompleteDetails.Serialization.cs @@ -8,130 +8,129 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunIncompleteDetails : IJsonModel { - public partial class RunIncompleteDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("reason") != true && Optional.IsDefined(Reason)) - { - writer.WritePropertyName("reason"u8); - writer.WriteStringValue(Reason.Value.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("reason") != true && Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.Value.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunIncompleteDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunIncompleteDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunIncompleteDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support reading '{format}' format."); } - internal static RunIncompleteDetails DeserializeRunIncompleteDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunIncompleteDetails(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - RunIncompleteReason? reason = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static RunIncompleteDetails DeserializeRunIncompleteDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunIncompleteReason? reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reason"u8)) { - if (property.NameEquals("reason"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - reason = new RunIncompleteReason(property.Value.GetString()); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + reason = new RunIncompleteReason(property.Value.GetString()); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunIncompleteDetails(reason, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunIncompleteDetails(reason, serializedAdditionalRawData); + } - RunIncompleteDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunIncompleteDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + RunIncompleteDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunIncompleteDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunIncompleteDetails(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunIncompleteDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunIncompleteDetails)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunIncompleteDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunIncompleteDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunIncompleteDetails.cs b/src/Generated/Models/RunIncompleteDetails.cs index 5c063d7c..b93862bd 100644 --- a/src/Generated/Models/RunIncompleteDetails.cs +++ b/src/Generated/Models/RunIncompleteDetails.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunIncompleteDetails { - public partial class RunIncompleteDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + internal RunIncompleteDetails() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunIncompleteDetails() - { - } - - internal RunIncompleteDetails(RunIncompleteReason? reason, IDictionary serializedAdditionalRawData) - { - Reason = reason; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public RunIncompleteReason? Reason { get; } + internal RunIncompleteDetails(RunIncompleteReason? reason, IDictionary serializedAdditionalRawData) + { + Reason = reason; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public RunIncompleteReason? Reason { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunIncompleteReason.cs b/src/Generated/Models/RunIncompleteReason.cs index b0baa9e8..faae8b94 100644 --- a/src/Generated/Models/RunIncompleteReason.cs +++ b/src/Generated/Models/RunIncompleteReason.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunIncompleteReason : IEquatable { - public readonly partial struct RunIncompleteReason : IEquatable - { - private readonly string _value; + private readonly string _value; - public RunIncompleteReason(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public RunIncompleteReason(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string MaxCompletionTokensValue = "max_completion_tokens"; - private const string MaxPromptTokensValue = "max_prompt_tokens"; + private const string MaxCompletionTokensValue = "max_completion_tokens"; + private const string MaxPromptTokensValue = "max_prompt_tokens"; - public static RunIncompleteReason MaxCompletionTokens { get; } = new RunIncompleteReason(MaxCompletionTokensValue); - public static RunIncompleteReason MaxPromptTokens { get; } = new RunIncompleteReason(MaxPromptTokensValue); - public static bool operator ==(RunIncompleteReason left, RunIncompleteReason right) => left.Equals(right); - public static bool operator !=(RunIncompleteReason left, RunIncompleteReason right) => !left.Equals(right); - public static implicit operator RunIncompleteReason(string value) => new RunIncompleteReason(value); + public static RunIncompleteReason MaxCompletionTokens { get; } = new RunIncompleteReason(MaxCompletionTokensValue); + public static RunIncompleteReason MaxPromptTokens { get; } = new RunIncompleteReason(MaxPromptTokensValue); + public static bool operator ==(RunIncompleteReason left, RunIncompleteReason right) => left.Equals(right); + public static bool operator !=(RunIncompleteReason left, RunIncompleteReason right) => !left.Equals(right); + public static implicit operator RunIncompleteReason(string value) => new RunIncompleteReason(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunIncompleteReason other && Equals(other); - public bool Equals(RunIncompleteReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunIncompleteReason other && Equals(other); + public bool Equals(RunIncompleteReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunModificationOptions.Serialization.cs b/src/Generated/Models/RunModificationOptions.Serialization.cs index f13f9b1a..205dc6d4 100644 --- a/src/Generated/Models/RunModificationOptions.Serialization.cs +++ b/src/Generated/Models/RunModificationOptions.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunModificationOptions : IJsonModel { - public partial class RunModificationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunModificationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunModificationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("metadata"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("metadata"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunModificationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunModificationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(RunModificationOptions)} does not support reading '{format}' format."); } - internal static RunModificationOptions DeserializeRunModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunModificationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static RunModificationOptions DeserializeRunModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadata"u8)) { - if (property.NameEquals("metadata"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunModificationOptions(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunModificationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunModificationOptions(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - RunModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunModificationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunModificationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunModificationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + RunModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunModificationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunModificationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunModificationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunModificationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunModificationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunModificationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunModificationOptions.cs b/src/Generated/Models/RunModificationOptions.cs index b9c29be4..fe473f60 100644 --- a/src/Generated/Models/RunModificationOptions.cs +++ b/src/Generated/Models/RunModificationOptions.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunModificationOptions { - public partial class RunModificationOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public RunModificationOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public RunModificationOptions() - { - Metadata = new ChangeTrackingDictionary(); - } - - internal RunModificationOptions(IDictionary metadata, IDictionary serializedAdditionalRawData) - { - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Metadata = new ChangeTrackingDictionary(); + } - public IDictionary Metadata { get; set; } + internal RunModificationOptions(IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IDictionary Metadata { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStatus.cs b/src/Generated/Models/RunStatus.cs index 08c6af67..95ff24fd 100644 --- a/src/Generated/Models/RunStatus.cs +++ b/src/Generated/Models/RunStatus.cs @@ -5,46 +5,45 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunStatus : IEquatable { - public readonly partial struct RunStatus : IEquatable + private readonly string _value; + + public RunStatus(string value) { - private readonly string _value; - - public RunStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string QueuedValue = "queued"; - private const string InProgressValue = "in_progress"; - private const string RequiresActionValue = "requires_action"; - private const string CancellingValue = "cancelling"; - private const string CancelledValue = "cancelled"; - private const string FailedValue = "failed"; - private const string CompletedValue = "completed"; - private const string IncompleteValue = "incomplete"; - private const string ExpiredValue = "expired"; - - public static RunStatus Queued { get; } = new RunStatus(QueuedValue); - public static RunStatus InProgress { get; } = new RunStatus(InProgressValue); - public static RunStatus RequiresAction { get; } = new RunStatus(RequiresActionValue); - public static RunStatus Cancelling { get; } = new RunStatus(CancellingValue); - public static RunStatus Cancelled { get; } = new RunStatus(CancelledValue); - public static RunStatus Failed { get; } = new RunStatus(FailedValue); - public static RunStatus Completed { get; } = new RunStatus(CompletedValue); - public static RunStatus Incomplete { get; } = new RunStatus(IncompleteValue); - public static RunStatus Expired { get; } = new RunStatus(ExpiredValue); - public static bool operator ==(RunStatus left, RunStatus right) => left.Equals(right); - public static bool operator !=(RunStatus left, RunStatus right) => !left.Equals(right); - public static implicit operator RunStatus(string value) => new RunStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStatus other && Equals(other); - public bool Equals(RunStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string QueuedValue = "queued"; + private const string InProgressValue = "in_progress"; + private const string RequiresActionValue = "requires_action"; + private const string CancellingValue = "cancelling"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + private const string ExpiredValue = "expired"; + + public static RunStatus Queued { get; } = new RunStatus(QueuedValue); + public static RunStatus InProgress { get; } = new RunStatus(InProgressValue); + public static RunStatus RequiresAction { get; } = new RunStatus(RequiresActionValue); + public static RunStatus Cancelling { get; } = new RunStatus(CancellingValue); + public static RunStatus Cancelled { get; } = new RunStatus(CancelledValue); + public static RunStatus Failed { get; } = new RunStatus(FailedValue); + public static RunStatus Completed { get; } = new RunStatus(CompletedValue); + public static RunStatus Incomplete { get; } = new RunStatus(IncompleteValue); + public static RunStatus Expired { get; } = new RunStatus(ExpiredValue); + public static bool operator ==(RunStatus left, RunStatus right) => left.Equals(right); + public static bool operator !=(RunStatus left, RunStatus right) => !left.Equals(right); + public static implicit operator RunStatus(string value) => new RunStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStatus other && Equals(other); + public bool Equals(RunStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunStep.Serialization.cs b/src/Generated/Models/RunStep.Serialization.cs index c31d89f5..b2645d37 100644 --- a/src/Generated/Models/RunStep.Serialization.cs +++ b/src/Generated/Models/RunStep.Serialization.cs @@ -8,403 +8,402 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStep : IJsonModel { - public partial class RunStep : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStep)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStep)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + { + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + } + if (SerializedAdditionalRawData?.ContainsKey("thread_id") != true) + { + writer.WritePropertyName("thread_id"u8); + writer.WriteStringValue(ThreadId); + } + if (SerializedAdditionalRawData?.ContainsKey("run_id") != true) + { + writer.WritePropertyName("run_id"u8); + writer.WriteStringValue(RunId); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("step_details") != true) + { + writer.WritePropertyName("step_details"u8); + writer.WriteObjectValue(Details, options); + } + if (SerializedAdditionalRawData?.ContainsKey("last_error") != true) + { + if (LastError != null) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("last_error"u8); + writer.WriteObjectValue(LastError, options); } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + else { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WriteNull("last_error"); } - if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("expired_at") != true) + { + if (ExpiredAt != null) { - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); + writer.WritePropertyName("expired_at"u8); + writer.WriteNumberValue(ExpiredAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("thread_id") != true) + else { - writer.WritePropertyName("thread_id"u8); - writer.WriteStringValue(ThreadId); + writer.WriteNull("expired_at"); } - if (SerializedAdditionalRawData?.ContainsKey("run_id") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("cancelled_at") != true) + { + if (CancelledAt != null) { - writer.WritePropertyName("run_id"u8); - writer.WriteStringValue(RunId); + writer.WritePropertyName("cancelled_at"u8); + writer.WriteNumberValue(CancelledAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) + else { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type.ToString()); + writer.WriteNull("cancelled_at"); } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("failed_at") != true) + { + if (FailedAt != null) { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("failed_at"u8); + writer.WriteNumberValue(FailedAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("step_details") != true) + else { - writer.WritePropertyName("step_details"u8); - writer.WriteObjectValue(Details, options); + writer.WriteNull("failed_at"); } - if (SerializedAdditionalRawData?.ContainsKey("last_error") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true) + { + if (CompletedAt != null) { - if (LastError != null) - { - writer.WritePropertyName("last_error"u8); - writer.WriteObjectValue(LastError, options); - } - else - { - writer.WriteNull("last_error"); - } + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("expired_at") != true) + else { - if (ExpiredAt != null) - { - writer.WritePropertyName("expired_at"u8); - writer.WriteNumberValue(ExpiredAt.Value, "U"); - } - else - { - writer.WriteNull("expired_at"); - } + writer.WriteNull("completed_at"); } - if (SerializedAdditionalRawData?.ContainsKey("cancelled_at") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + { + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { - if (CancelledAt != null) - { - writer.WritePropertyName("cancelled_at"u8); - writer.WriteNumberValue(CancelledAt.Value, "U"); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("cancelled_at"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("failed_at") != true) + else { - if (FailedAt != null) - { - writer.WritePropertyName("failed_at"u8); - writer.WriteNumberValue(FailedAt.Value, "U"); - } - else - { - writer.WriteNull("failed_at"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("usage") != true) + { + if (Usage != null) { - if (CompletedAt != null) - { - writer.WritePropertyName("completed_at"u8); - writer.WriteNumberValue(CompletedAt.Value, "U"); - } - else - { - writer.WriteNull("completed_at"); - } + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + else { - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WriteNull("usage"); } - if (SerializedAdditionalRawData?.ContainsKey("usage") != true) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Usage != null) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - else - { - writer.WriteNull("usage"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStep IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStep)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStep(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStep)} does not support reading '{format}' format."); } - internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStep(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - InternalRunStepObjectObject @object = default; - DateTimeOffset createdAt = default; - string assistantId = default; - string threadId = default; - string runId = default; - RunStepType type = default; - RunStepStatus status = default; - RunStepDetails stepDetails = default; - RunStepError lastError = default; - DateTimeOffset? expiredAt = default; - DateTimeOffset? cancelledAt = default; - DateTimeOffset? failedAt = default; - DateTimeOffset? completedAt = default; - IReadOnlyDictionary metadata = default; - RunStepTokenUsage usage = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalRunStepObjectObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("assistant_id"u8)) - { - assistantId = property.Value.GetString(); - continue; - } - if (property.NameEquals("thread_id"u8)) - { - threadId = property.Value.GetString(); - continue; - } - if (property.NameEquals("run_id"u8)) - { - runId = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new RunStepType(property.Value.GetString()); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new RunStepStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("step_details"u8)) + internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalRunStepObjectObject @object = default; + DateTimeOffset createdAt = default; + string assistantId = default; + string threadId = default; + string runId = default; + RunStepType type = default; + RunStepStatus status = default; + RunStepDetails stepDetails = default; + RunStepError lastError = default; + DateTimeOffset? expiredAt = default; + DateTimeOffset? cancelledAt = default; + DateTimeOffset? failedAt = default; + DateTimeOffset? completedAt = default; + IReadOnlyDictionary metadata = default; + RunStepTokenUsage usage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalRunStepObjectObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("thread_id"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("run_id"u8)) + { + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new RunStepType(property.Value.GetString()); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new RunStepStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("step_details"u8)) + { + stepDetails = RunStepDetails.DeserializeRunStepDetails(property.Value, options); + continue; + } + if (property.NameEquals("last_error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - stepDetails = RunStepDetails.DeserializeRunStepDetails(property.Value, options); + lastError = null; continue; } - if (property.NameEquals("last_error"u8)) + lastError = RunStepError.DeserializeRunStepError(property.Value, options); + continue; + } + if (property.NameEquals("expired_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastError = null; - continue; - } - lastError = RunStepError.DeserializeRunStepError(property.Value, options); + expiredAt = null; continue; } - if (property.NameEquals("expired_at"u8)) + expiredAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("cancelled_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - expiredAt = null; - continue; - } - expiredAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + cancelledAt = null; continue; } - if (property.NameEquals("cancelled_at"u8)) + cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("failed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - cancelledAt = null; - continue; - } - cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + failedAt = null; continue; } - if (property.NameEquals("failed_at"u8)) + failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - failedAt = null; - continue; - } - failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + completedAt = null; continue; } - if (property.NameEquals("completed_at"u8)) + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - completedAt = null; - continue; - } - completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + metadata = new ChangeTrackingDictionary(); continue; } - if (property.NameEquals("metadata"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; - continue; + dictionary.Add(property0.Name, property0.Value.GetString()); } - if (property.NameEquals("usage"u8)) + metadata = dictionary; + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - usage = null; - continue; - } - usage = RunStepTokenUsage.DeserializeRunStepTokenUsage(property.Value, options); + usage = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + usage = RunStepTokenUsage.DeserializeRunStepTokenUsage(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunStep( - id, - @object, - createdAt, - assistantId, - threadId, - runId, - type, - status, - stepDetails, - lastError, - expiredAt, - cancelledAt, - failedAt, - completedAt, - metadata, - usage, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStep)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunStep( + id, + @object, + createdAt, + assistantId, + threadId, + runId, + type, + status, + stepDetails, + lastError, + expiredAt, + cancelledAt, + failedAt, + completedAt, + metadata, + usage, + serializedAdditionalRawData); + } - RunStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStep(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStep)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStep)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + RunStep IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStep FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStep(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStep(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStep)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStep FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStep(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunStep.cs b/src/Generated/Models/RunStep.cs index e6d00c19..01140abc 100644 --- a/src/Generated/Models/RunStep.cs +++ b/src/Generated/Models/RunStep.cs @@ -5,75 +5,74 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStep { - public partial class RunStep + internal IDictionary SerializedAdditionalRawData { get; set; } + internal RunStep(string id, DateTimeOffset createdAt, string assistantId, string threadId, string runId, RunStepType type, RunStepStatus status, RunStepDetails details, RunStepError lastError, DateTimeOffset? expiredAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, IReadOnlyDictionary metadata, RunStepTokenUsage usage) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunStep(string id, DateTimeOffset createdAt, string assistantId, string threadId, string runId, RunStepType type, RunStepStatus status, RunStepDetails details, RunStepError lastError, DateTimeOffset? expiredAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, IReadOnlyDictionary metadata, RunStepTokenUsage usage) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(assistantId, nameof(assistantId)); - Argument.AssertNotNull(threadId, nameof(threadId)); - Argument.AssertNotNull(runId, nameof(runId)); - Argument.AssertNotNull(details, nameof(details)); + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(assistantId, nameof(assistantId)); + Argument.AssertNotNull(threadId, nameof(threadId)); + Argument.AssertNotNull(runId, nameof(runId)); + Argument.AssertNotNull(details, nameof(details)); - Id = id; - CreatedAt = createdAt; - AssistantId = assistantId; - ThreadId = threadId; - RunId = runId; - Type = type; - Status = status; - Details = details; - LastError = lastError; - ExpiredAt = expiredAt; - CancelledAt = cancelledAt; - FailedAt = failedAt; - CompletedAt = completedAt; - Metadata = metadata; - Usage = usage; - } + Id = id; + CreatedAt = createdAt; + AssistantId = assistantId; + ThreadId = threadId; + RunId = runId; + Type = type; + Status = status; + Details = details; + LastError = lastError; + ExpiredAt = expiredAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + CompletedAt = completedAt; + Metadata = metadata; + Usage = usage; + } - internal RunStep(string id, InternalRunStepObjectObject @object, DateTimeOffset createdAt, string assistantId, string threadId, string runId, RunStepType type, RunStepStatus status, RunStepDetails details, RunStepError lastError, DateTimeOffset? expiredAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, IReadOnlyDictionary metadata, RunStepTokenUsage usage, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - AssistantId = assistantId; - ThreadId = threadId; - RunId = runId; - Type = type; - Status = status; - Details = details; - LastError = lastError; - ExpiredAt = expiredAt; - CancelledAt = cancelledAt; - FailedAt = failedAt; - CompletedAt = completedAt; - Metadata = metadata; - Usage = usage; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal RunStep(string id, InternalRunStepObjectObject @object, DateTimeOffset createdAt, string assistantId, string threadId, string runId, RunStepType type, RunStepStatus status, RunStepDetails details, RunStepError lastError, DateTimeOffset? expiredAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, IReadOnlyDictionary metadata, RunStepTokenUsage usage, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + AssistantId = assistantId; + ThreadId = threadId; + RunId = runId; + Type = type; + Status = status; + Details = details; + LastError = lastError; + ExpiredAt = expiredAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + CompletedAt = completedAt; + Metadata = metadata; + Usage = usage; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal RunStep() - { - } + internal RunStep() + { + } - public string Id { get; } + public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public string AssistantId { get; } - public string ThreadId { get; } - public string RunId { get; } - public RunStepType Type { get; } - public RunStepStatus Status { get; } - public RunStepError LastError { get; } - public DateTimeOffset? ExpiredAt { get; } - public DateTimeOffset? CancelledAt { get; } - public DateTimeOffset? FailedAt { get; } - public DateTimeOffset? CompletedAt { get; } - public IReadOnlyDictionary Metadata { get; } - public RunStepTokenUsage Usage { get; } - } -} + public DateTimeOffset CreatedAt { get; } + public string AssistantId { get; } + public string ThreadId { get; } + public string RunId { get; } + public RunStepType Type { get; } + public RunStepStatus Status { get; } + public RunStepError LastError { get; } + public DateTimeOffset? ExpiredAt { get; } + public DateTimeOffset? CancelledAt { get; } + public DateTimeOffset? FailedAt { get; } + public DateTimeOffset? CompletedAt { get; } + public IReadOnlyDictionary Metadata { get; } + public RunStepTokenUsage Usage { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepCodeInterpreterOutput.Serialization.cs b/src/Generated/Models/RunStepCodeInterpreterOutput.Serialization.cs index f7ef0766..84e40c6b 100644 --- a/src/Generated/Models/RunStepCodeInterpreterOutput.Serialization.cs +++ b/src/Generated/Models/RunStepCodeInterpreterOutput.Serialization.cs @@ -7,118 +7,117 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject))] +public partial class RunStepCodeInterpreterOutput : IJsonModel { - [PersistableModelProxy(typeof(UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject))] - public partial class RunStepCodeInterpreterOutput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStepCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{format}' format."); } - internal static RunStepCodeInterpreterOutput DeserializeRunStepCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "image": return InternalRunStepDetailsToolCallsCodeOutputImageObject.DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(element, options); - case "logs": return InternalRunStepCodeInterpreterLogOutput.DeserializeInternalRunStepCodeInterpreterLogOutput(element, options); - } - } - return UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.DeserializeUnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(element, options); - } + internal static RunStepCodeInterpreterOutput DeserializeRunStepCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{options.Format}' format."); - } + return null; } - - RunStepCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + case "image": return InternalRunStepDetailsToolCallsCodeOutputImageObject.DeserializeInternalRunStepDetailsToolCallsCodeOutputImageObject(element, options); + case "logs": return InternalRunStepCodeInterpreterLogOutput.DeserializeInternalRunStepCodeInterpreterLogOutput(element, options); } } + return UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.DeserializeUnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStepCodeInterpreterOutput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepCodeInterpreterOutput(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + RunStepCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStepCodeInterpreterOutput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepCodeInterpreterOutput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepCodeInterpreterOutput.cs b/src/Generated/Models/RunStepCodeInterpreterOutput.cs index 1419ce55..9120fbd4 100644 --- a/src/Generated/Models/RunStepCodeInterpreterOutput.cs +++ b/src/Generated/Models/RunStepCodeInterpreterOutput.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public abstract partial class RunStepCodeInterpreterOutput { - public abstract partial class RunStepCodeInterpreterOutput + internal IDictionary SerializedAdditionalRawData { get; set; } + protected RunStepCodeInterpreterOutput() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected RunStepCodeInterpreterOutput() - { - } - - internal RunStepCodeInterpreterOutput(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal RunStepCodeInterpreterOutput(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepCollectionOrder.cs b/src/Generated/Models/RunStepCollectionOrder.cs index a818d310..34935c61 100644 --- a/src/Generated/Models/RunStepCollectionOrder.cs +++ b/src/Generated/Models/RunStepCollectionOrder.cs @@ -5,29 +5,28 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunStepCollectionOrder : IEquatable { - public readonly partial struct RunStepCollectionOrder : IEquatable + private readonly string _value; + + public RunStepCollectionOrder(string value) { - private readonly string _value; - - public RunStepCollectionOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AscendingValue = "asc"; - private const string DescendingValue = "desc"; - public static bool operator ==(RunStepCollectionOrder left, RunStepCollectionOrder right) => left.Equals(right); - public static bool operator !=(RunStepCollectionOrder left, RunStepCollectionOrder right) => !left.Equals(right); - public static implicit operator RunStepCollectionOrder(string value) => new RunStepCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepCollectionOrder other && Equals(other); - public bool Equals(RunStepCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AscendingValue = "asc"; + private const string DescendingValue = "desc"; + public static bool operator ==(RunStepCollectionOrder left, RunStepCollectionOrder right) => left.Equals(right); + public static bool operator !=(RunStepCollectionOrder left, RunStepCollectionOrder right) => !left.Equals(right); + public static implicit operator RunStepCollectionOrder(string value) => new RunStepCollectionOrder(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepCollectionOrder other && Equals(other); + public bool Equals(RunStepCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepDetails.Serialization.cs b/src/Generated/Models/RunStepDetails.Serialization.cs index 35e15ea1..1a7694e4 100644 --- a/src/Generated/Models/RunStepDetails.Serialization.cs +++ b/src/Generated/Models/RunStepDetails.Serialization.cs @@ -7,118 +7,117 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownRunStepObjectStepDetails))] +public partial class RunStepDetails : IJsonModel { - [PersistableModelProxy(typeof(UnknownRunStepObjectStepDetails))] - public partial class RunStepDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDetails(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{format}' format."); } - internal static RunStepDetails DeserializeRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDetails(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "message_creation": return InternalRunStepDetailsMessageCreationObject.DeserializeInternalRunStepDetailsMessageCreationObject(element, options); - case "tool_calls": return InternalRunStepDetailsToolCallsObject.DeserializeInternalRunStepDetailsToolCallsObject(element, options); - } - } - return UnknownRunStepObjectStepDetails.DeserializeUnknownRunStepObjectStepDetails(element, options); - } + internal static RunStepDetails DeserializeRunStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); - } + return null; } - - RunStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{options.Format}' format."); + case "message_creation": return InternalRunStepDetailsMessageCreationObject.DeserializeInternalRunStepDetailsMessageCreationObject(element, options); + case "tool_calls": return InternalRunStepDetailsToolCallsObject.DeserializeInternalRunStepDetailsToolCallsObject(element, options); } } + return UnknownRunStepObjectStepDetails.DeserializeUnknownRunStepObjectStepDetails(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStepDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + RunStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStepDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDetails(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepDetails.cs b/src/Generated/Models/RunStepDetails.cs index 29a98a67..3a03c0e0 100644 --- a/src/Generated/Models/RunStepDetails.cs +++ b/src/Generated/Models/RunStepDetails.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public abstract partial class RunStepDetails { - public abstract partial class RunStepDetails + internal IDictionary SerializedAdditionalRawData { get; set; } + protected RunStepDetails() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected RunStepDetails() - { - } - - internal RunStepDetails(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal RunStepDetails(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepError.Serialization.cs b/src/Generated/Models/RunStepError.Serialization.cs index 2e84d4c8..6b0e3958 100644 --- a/src/Generated/Models/RunStepError.Serialization.cs +++ b/src/Generated/Models/RunStepError.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStepError : IJsonModel { - public partial class RunStepError : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepError)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStepError)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code") != true) - { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) - { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code") != true) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStepError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepError(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStepError)} does not support reading '{format}' format."); } - internal static RunStepError DeserializeRunStepError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepError(document.RootElement, options); + } + + internal static RunStepError DeserializeRunStepError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepErrorCode code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) { - return null; + code = new RunStepErrorCode(property.Value.GetString()); + continue; } - RunStepErrorCode code = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("message"u8)) { - if (property.NameEquals("code"u8)) - { - code = new RunStepErrorCode(property.Value.GetString()); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + message = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepError(code, message, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepError)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepError(code, message, serializedAdditionalRawData); + } - RunStepError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepError)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepError)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + RunStepError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStepError FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepError(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepError)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStepError FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepError(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepError.cs b/src/Generated/Models/RunStepError.cs index 780003cb..dc74abc7 100644 --- a/src/Generated/Models/RunStepError.cs +++ b/src/Generated/Models/RunStepError.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStepError { - public partial class RunStepError + internal IDictionary SerializedAdditionalRawData { get; set; } + internal RunStepError(RunStepErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + } + + internal RunStepError(RunStepErrorCode code, string message, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunStepError(RunStepErrorCode code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - } - - internal RunStepError(RunStepErrorCode code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal RunStepError() - { - } - - public RunStepErrorCode Code { get; } - public string Message { get; } + Code = code; + Message = message; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal RunStepError() + { + } + + public RunStepErrorCode Code { get; } + public string Message { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepErrorCode.cs b/src/Generated/Models/RunStepErrorCode.cs index 3feed9ad..8894e129 100644 --- a/src/Generated/Models/RunStepErrorCode.cs +++ b/src/Generated/Models/RunStepErrorCode.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunStepErrorCode : IEquatable { - public readonly partial struct RunStepErrorCode : IEquatable - { - private readonly string _value; + private readonly string _value; - public RunStepErrorCode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public RunStepErrorCode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string ServerErrorValue = "server_error"; - private const string RateLimitExceededValue = "rate_limit_exceeded"; + private const string ServerErrorValue = "server_error"; + private const string RateLimitExceededValue = "rate_limit_exceeded"; - public static RunStepErrorCode ServerError { get; } = new RunStepErrorCode(ServerErrorValue); - public static RunStepErrorCode RateLimitExceeded { get; } = new RunStepErrorCode(RateLimitExceededValue); - public static bool operator ==(RunStepErrorCode left, RunStepErrorCode right) => left.Equals(right); - public static bool operator !=(RunStepErrorCode left, RunStepErrorCode right) => !left.Equals(right); - public static implicit operator RunStepErrorCode(string value) => new RunStepErrorCode(value); + public static RunStepErrorCode ServerError { get; } = new RunStepErrorCode(ServerErrorValue); + public static RunStepErrorCode RateLimitExceeded { get; } = new RunStepErrorCode(RateLimitExceededValue); + public static bool operator ==(RunStepErrorCode left, RunStepErrorCode right) => left.Equals(right); + public static bool operator !=(RunStepErrorCode left, RunStepErrorCode right) => !left.Equals(right); + public static implicit operator RunStepErrorCode(string value) => new RunStepErrorCode(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepErrorCode other && Equals(other); - public bool Equals(RunStepErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepErrorCode other && Equals(other); + public bool Equals(RunStepErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepFileSearchResult.Serialization.cs b/src/Generated/Models/RunStepFileSearchResult.Serialization.cs index 2bd5b0e7..2102d84c 100644 --- a/src/Generated/Models/RunStepFileSearchResult.Serialization.cs +++ b/src/Generated/Models/RunStepFileSearchResult.Serialization.cs @@ -8,173 +8,172 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStepFileSearchResult : IJsonModel { - public partial class RunStepFileSearchResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) - { - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("file_name") != true) - { - writer.WritePropertyName("file_name"u8); - writer.WriteStringValue(FileName); - } - if (SerializedAdditionalRawData?.ContainsKey("score") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_id") != true) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("file_name") != true) + { + writer.WritePropertyName("file_name"u8); + writer.WriteStringValue(FileName); + } + if (SerializedAdditionalRawData?.ContainsKey("score") != true) + { + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score); + } + if (SerializedAdditionalRawData?.ContainsKey("content") != true && Optional.IsCollectionDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) { - writer.WritePropertyName("score"u8); - writer.WriteNumberValue(Score); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("content") != true && Optional.IsCollectionDefined(Content)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("content"u8); - writer.WriteStartArray(); - foreach (var item in Content) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteObjectValue(item, options); + continue; } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStepFileSearchResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepFileSearchResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepFileSearchResult(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support reading '{format}' format."); } - internal static RunStepFileSearchResult DeserializeRunStepFileSearchResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepFileSearchResult(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static RunStepFileSearchResult DeserializeRunStepFileSearchResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string fileName = default; + float score = default; + IReadOnlyList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) { - return null; + fileId = property.Value.GetString(); + continue; } - string fileId = default; - string fileName = default; - float score = default; - IReadOnlyList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("file_name"u8)) { - if (property.NameEquals("file_id"u8)) - { - fileId = property.Value.GetString(); - continue; - } - if (property.NameEquals("file_name"u8)) - { - fileName = property.Value.GetString(); - continue; - } - if (property.NameEquals("score"u8)) - { - score = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("content"u8)) + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("score"u8)) + { + score = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("content"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalRunStepDetailsToolCallsFileSearchResultObjectContent.DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(item, options)); - } - content = array; continue; } - if (true) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + array.Add(InternalRunStepDetailsToolCallsFileSearchResultObjectContent.DeserializeInternalRunStepDetailsToolCallsFileSearchResultObjectContent(item, options)); } + content = array; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepFileSearchResult(fileId, fileName, score, content ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepFileSearchResult(fileId, fileName, score, content ?? new ChangeTrackingList(), serializedAdditionalRawData); + } - RunStepFileSearchResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepFileSearchResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + RunStepFileSearchResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStepFileSearchResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepFileSearchResult(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepFileSearchResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepFileSearchResult)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStepFileSearchResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepFileSearchResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepFileSearchResult.cs b/src/Generated/Models/RunStepFileSearchResult.cs index 02e968db..28a3c2b6 100644 --- a/src/Generated/Models/RunStepFileSearchResult.cs +++ b/src/Generated/Models/RunStepFileSearchResult.cs @@ -5,37 +5,36 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStepFileSearchResult { - public partial class RunStepFileSearchResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal RunStepFileSearchResult(string fileId, string fileName, float score) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(fileName, nameof(fileName)); + + FileId = fileId; + FileName = fileName; + Score = score; + Content = new ChangeTrackingList(); + } + + internal RunStepFileSearchResult(string fileId, string fileName, float score, IReadOnlyList content, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunStepFileSearchResult(string fileId, string fileName, float score) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - Argument.AssertNotNull(fileName, nameof(fileName)); - - FileId = fileId; - FileName = fileName; - Score = score; - Content = new ChangeTrackingList(); - } - - internal RunStepFileSearchResult(string fileId, string fileName, float score, IReadOnlyList content, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - FileName = fileName; - Score = score; - Content = content; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal RunStepFileSearchResult() - { - } - - public string FileId { get; } - public string FileName { get; } - public float Score { get; } + FileId = fileId; + FileName = fileName; + Score = score; + Content = content; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal RunStepFileSearchResult() + { + } + + public string FileId { get; } + public string FileName { get; } + public float Score { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepStatus.cs b/src/Generated/Models/RunStepStatus.cs index b328305d..2caa205e 100644 --- a/src/Generated/Models/RunStepStatus.cs +++ b/src/Generated/Models/RunStepStatus.cs @@ -5,38 +5,37 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunStepStatus : IEquatable { - public readonly partial struct RunStepStatus : IEquatable + private readonly string _value; + + public RunStepStatus(string value) { - private readonly string _value; - - public RunStepStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string CancelledValue = "cancelled"; - private const string FailedValue = "failed"; - private const string CompletedValue = "completed"; - private const string ExpiredValue = "expired"; - - public static RunStepStatus InProgress { get; } = new RunStepStatus(InProgressValue); - public static RunStepStatus Cancelled { get; } = new RunStepStatus(CancelledValue); - public static RunStepStatus Failed { get; } = new RunStepStatus(FailedValue); - public static RunStepStatus Completed { get; } = new RunStepStatus(CompletedValue); - public static RunStepStatus Expired { get; } = new RunStepStatus(ExpiredValue); - public static bool operator ==(RunStepStatus left, RunStepStatus right) => left.Equals(right); - public static bool operator !=(RunStepStatus left, RunStepStatus right) => !left.Equals(right); - public static implicit operator RunStepStatus(string value) => new RunStepStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepStatus other && Equals(other); - public bool Equals(RunStepStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string InProgressValue = "in_progress"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + private const string CompletedValue = "completed"; + private const string ExpiredValue = "expired"; + + public static RunStepStatus InProgress { get; } = new RunStepStatus(InProgressValue); + public static RunStepStatus Cancelled { get; } = new RunStepStatus(CancelledValue); + public static RunStepStatus Failed { get; } = new RunStepStatus(FailedValue); + public static RunStepStatus Completed { get; } = new RunStepStatus(CompletedValue); + public static RunStepStatus Expired { get; } = new RunStepStatus(ExpiredValue); + public static bool operator ==(RunStepStatus left, RunStepStatus right) => left.Equals(right); + public static bool operator !=(RunStepStatus left, RunStepStatus right) => !left.Equals(right); + public static implicit operator RunStepStatus(string value) => new RunStepStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepStatus other && Equals(other); + public bool Equals(RunStepStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepTokenUsage.Serialization.cs b/src/Generated/Models/RunStepTokenUsage.Serialization.cs index eed20e75..1b307e7c 100644 --- a/src/Generated/Models/RunStepTokenUsage.Serialization.cs +++ b/src/Generated/Models/RunStepTokenUsage.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStepTokenUsage : IJsonModel { - public partial class RunStepTokenUsage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) - { - writer.WritePropertyName("completion_tokens"u8); - writer.WriteNumberValue(CompletionTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) - { - writer.WritePropertyName("prompt_tokens"u8); - writer.WriteNumberValue(PromptTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) - { - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) + { + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(CompletionTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) + { + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(PromptTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) + { + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStepTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepTokenUsage(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support reading '{format}' format."); } - internal static RunStepTokenUsage DeserializeRunStepTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepTokenUsage(document.RootElement, options); + } + + internal static RunStepTokenUsage DeserializeRunStepTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int completionTokens = default; + int promptTokens = default; + int totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) { - return null; + completionTokens = property.Value.GetInt32(); + continue; } - int completionTokens = default; - int promptTokens = default; - int totalTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("prompt_tokens"u8)) { - if (property.NameEquals("completion_tokens"u8)) - { - completionTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("prompt_tokens"u8)) - { - promptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total_tokens"u8)) - { - totalTokens = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + promptTokens = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunStepTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("total_tokens"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support writing '{options.Format}' format."); + totalTokens = property.Value.GetInt32(); + continue; } - } - - RunStepTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepTokenUsage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStepTokenUsage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepTokenUsage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support writing '{options.Format}' format."); } + } + + RunStepTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepTokenUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepTokenUsage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStepTokenUsage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepTokenUsage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepTokenUsage.cs b/src/Generated/Models/RunStepTokenUsage.cs index 3e1e8193..a3195973 100644 --- a/src/Generated/Models/RunStepTokenUsage.cs +++ b/src/Generated/Models/RunStepTokenUsage.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunStepTokenUsage { - public partial class RunStepTokenUsage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal RunStepTokenUsage(int completionTokens, int promptTokens, int totalTokens) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunStepTokenUsage(int completionTokens, int promptTokens, int totalTokens) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - } - - internal RunStepTokenUsage(int completionTokens, int promptTokens, int totalTokens, IDictionary serializedAdditionalRawData) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + } - internal RunStepTokenUsage() - { - } + internal RunStepTokenUsage(int completionTokens, int promptTokens, int totalTokens, IDictionary serializedAdditionalRawData) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int CompletionTokens { get; } - public int PromptTokens { get; } - public int TotalTokens { get; } + internal RunStepTokenUsage() + { } -} + + public int CompletionTokens { get; } + public int PromptTokens { get; } + public int TotalTokens { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepToolCall.Serialization.cs b/src/Generated/Models/RunStepToolCall.Serialization.cs index 322ca021..a7bdc63a 100644 --- a/src/Generated/Models/RunStepToolCall.Serialization.cs +++ b/src/Generated/Models/RunStepToolCall.Serialization.cs @@ -7,119 +7,118 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownRunStepDetailsToolCallsObjectToolCallsObject))] +public partial class RunStepToolCall : IJsonModel { - [PersistableModelProxy(typeof(UnknownRunStepDetailsToolCallsObjectToolCallsObject))] - public partial class RunStepToolCall : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStepToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepToolCall(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{format}' format."); } - internal static RunStepToolCall DeserializeRunStepToolCall(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepToolCall(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "code_interpreter": return InternalRunStepCodeInterpreterToolCallDetails.DeserializeInternalRunStepCodeInterpreterToolCallDetails(element, options); - case "file_search": return InternalRunStepFileSearchToolCallDetails.DeserializeInternalRunStepFileSearchToolCallDetails(element, options); - case "function": return InternalRunStepFunctionToolCallDetails.DeserializeInternalRunStepFunctionToolCallDetails(element, options); - } - } - return UnknownRunStepDetailsToolCallsObjectToolCallsObject.DeserializeUnknownRunStepDetailsToolCallsObjectToolCallsObject(element, options); - } + internal static RunStepToolCall DeserializeRunStepToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); - } + return null; } - - RunStepToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{options.Format}' format."); + case "code_interpreter": return InternalRunStepCodeInterpreterToolCallDetails.DeserializeInternalRunStepCodeInterpreterToolCallDetails(element, options); + case "file_search": return InternalRunStepFileSearchToolCallDetails.DeserializeInternalRunStepFileSearchToolCallDetails(element, options); + case "function": return InternalRunStepFunctionToolCallDetails.DeserializeInternalRunStepFunctionToolCallDetails(element, options); } } + return UnknownRunStepDetailsToolCallsObjectToolCallsObject.DeserializeUnknownRunStepDetailsToolCallsObjectToolCallsObject(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStepToolCall FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepToolCall(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + RunStepToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStepToolCall FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepToolCall(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepToolCall.cs b/src/Generated/Models/RunStepToolCall.cs index 7c21afff..6a2d54a3 100644 --- a/src/Generated/Models/RunStepToolCall.cs +++ b/src/Generated/Models/RunStepToolCall.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public abstract partial class RunStepToolCall { - public abstract partial class RunStepToolCall + internal IDictionary SerializedAdditionalRawData { get; set; } + protected RunStepToolCall() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected RunStepToolCall() - { - } - - internal RunStepToolCall(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal RunStepToolCall(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepType.cs b/src/Generated/Models/RunStepType.cs index 699bc37a..f40cc924 100644 --- a/src/Generated/Models/RunStepType.cs +++ b/src/Generated/Models/RunStepType.cs @@ -5,32 +5,31 @@ using System; using System.ComponentModel; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public readonly partial struct RunStepType : IEquatable { - public readonly partial struct RunStepType : IEquatable - { - private readonly string _value; + private readonly string _value; - public RunStepType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + public RunStepType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } - private const string MessageCreationValue = "message_creation"; - private const string ToolCallsValue = "tool_calls"; + private const string MessageCreationValue = "message_creation"; + private const string ToolCallsValue = "tool_calls"; - public static RunStepType MessageCreation { get; } = new RunStepType(MessageCreationValue); - public static RunStepType ToolCalls { get; } = new RunStepType(ToolCallsValue); - public static bool operator ==(RunStepType left, RunStepType right) => left.Equals(right); - public static bool operator !=(RunStepType left, RunStepType right) => !left.Equals(right); - public static implicit operator RunStepType(string value) => new RunStepType(value); + public static RunStepType MessageCreation { get; } = new RunStepType(MessageCreationValue); + public static RunStepType ToolCalls { get; } = new RunStepType(ToolCallsValue); + public static bool operator ==(RunStepType left, RunStepType right) => left.Equals(right); + public static bool operator !=(RunStepType left, RunStepType right) => !left.Equals(right); + public static implicit operator RunStepType(string value) => new RunStepType(value); - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepType other && Equals(other); - public bool Equals(RunStepType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepType other && Equals(other); + public bool Equals(RunStepType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; - } -} + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.Serialization.cs b/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.Serialization.cs index 15407f30..5f10867f 100644 --- a/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.Serialization.cs +++ b/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.Serialization.cs @@ -7,118 +7,117 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject))] +public partial class RunStepUpdateCodeInterpreterOutput : IJsonModel { - [PersistableModelProxy(typeof(UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject))] - public partial class RunStepUpdateCodeInterpreterOutput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunStepUpdateCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepUpdateCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{format}' format."); } - internal static RunStepUpdateCodeInterpreterOutput DeserializeRunStepUpdateCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "image": return InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(element, options); - case "logs": return InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(element, options); - } - } - return UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.DeserializeUnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(element, options); - } + internal static RunStepUpdateCodeInterpreterOutput DeserializeRunStepUpdateCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{options.Format}' format."); - } + return null; } - - RunStepUpdateCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + case "image": return InternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputImageObject(element, options); + case "logs": return InternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsCodeOutputLogsObject(element, options); } } + return UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.DeserializeUnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunStepUpdateCodeInterpreterOutput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + RunStepUpdateCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunStepUpdateCodeInterpreterOutput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.cs b/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.cs index 63733210..e218e660 100644 --- a/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.cs +++ b/src/Generated/Models/RunStepUpdateCodeInterpreterOutput.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public abstract partial class RunStepUpdateCodeInterpreterOutput { - public abstract partial class RunStepUpdateCodeInterpreterOutput + internal IDictionary SerializedAdditionalRawData { get; set; } + protected RunStepUpdateCodeInterpreterOutput() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected RunStepUpdateCodeInterpreterOutput() - { - } - - internal RunStepUpdateCodeInterpreterOutput(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal RunStepUpdateCodeInterpreterOutput(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunTokenUsage.Serialization.cs b/src/Generated/Models/RunTokenUsage.Serialization.cs index 7f50758c..dd00b344 100644 --- a/src/Generated/Models/RunTokenUsage.Serialization.cs +++ b/src/Generated/Models/RunTokenUsage.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunTokenUsage : IJsonModel { - public partial class RunTokenUsage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunTokenUsage)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunTokenUsage)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) - { - writer.WritePropertyName("completion_tokens"u8); - writer.WriteNumberValue(CompletionTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) - { - writer.WritePropertyName("prompt_tokens"u8); - writer.WriteNumberValue(PromptTokens); - } - if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) - { - writer.WritePropertyName("total_tokens"u8); - writer.WriteNumberValue(TotalTokens); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("completion_tokens") != true) + { + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(CompletionTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("prompt_tokens") != true) + { + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(PromptTokens); + } + if (SerializedAdditionalRawData?.ContainsKey("total_tokens") != true) + { + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunTokenUsage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunTokenUsage(document.RootElement, options); + throw new FormatException($"The model {nameof(RunTokenUsage)} does not support reading '{format}' format."); } - internal static RunTokenUsage DeserializeRunTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunTokenUsage(document.RootElement, options); + } + + internal static RunTokenUsage DeserializeRunTokenUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int completionTokens = default; + int promptTokens = default; + int totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) { - return null; + completionTokens = property.Value.GetInt32(); + continue; } - int completionTokens = default; - int promptTokens = default; - int totalTokens = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("prompt_tokens"u8)) { - if (property.NameEquals("completion_tokens"u8)) - { - completionTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("prompt_tokens"u8)) - { - promptTokens = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total_tokens"u8)) - { - totalTokens = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + promptTokens = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("total_tokens"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunTokenUsage)} does not support writing '{options.Format}' format."); + totalTokens = property.Value.GetInt32(); + continue; } - } - - RunTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunTokenUsage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunTokenUsage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunTokenUsage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunTokenUsage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunTokenUsage)} does not support writing '{options.Format}' format."); } + } + + RunTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunTokenUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunTokenUsage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunTokenUsage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunTokenUsage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/RunTokenUsage.cs b/src/Generated/Models/RunTokenUsage.cs index c961964d..3900baba 100644 --- a/src/Generated/Models/RunTokenUsage.cs +++ b/src/Generated/Models/RunTokenUsage.cs @@ -5,32 +5,31 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunTokenUsage { - public partial class RunTokenUsage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal RunTokenUsage(int completionTokens, int promptTokens, int totalTokens) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal RunTokenUsage(int completionTokens, int promptTokens, int totalTokens) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - } - - internal RunTokenUsage(int completionTokens, int promptTokens, int totalTokens, IDictionary serializedAdditionalRawData) - { - CompletionTokens = completionTokens; - PromptTokens = promptTokens; - TotalTokens = totalTokens; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + } - internal RunTokenUsage() - { - } + internal RunTokenUsage(int completionTokens, int promptTokens, int totalTokens, IDictionary serializedAdditionalRawData) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int CompletionTokens { get; } - public int PromptTokens { get; } - public int TotalTokens { get; } + internal RunTokenUsage() + { } -} + + public int CompletionTokens { get; } + public int PromptTokens { get; } + public int TotalTokens { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/RunTruncationStrategy.Serialization.cs b/src/Generated/Models/RunTruncationStrategy.Serialization.cs index 7aad14eb..6636691b 100644 --- a/src/Generated/Models/RunTruncationStrategy.Serialization.cs +++ b/src/Generated/Models/RunTruncationStrategy.Serialization.cs @@ -8,149 +8,148 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunTruncationStrategy : IJsonModel { - public partial class RunTruncationStrategy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(_type.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("last_messages") != true && Optional.IsDefined(LastMessages)) + { + if (LastMessages != null) { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(_type.ToString()); + writer.WritePropertyName("last_messages"u8); + writer.WriteNumberValue(LastMessages.Value); } - if (SerializedAdditionalRawData?.ContainsKey("last_messages") != true && Optional.IsDefined(LastMessages)) + else { - if (LastMessages != null) - { - writer.WritePropertyName("last_messages"u8); - writer.WriteNumberValue(LastMessages.Value); - } - else - { - writer.WriteNull("last_messages"); - } + writer.WriteNull("last_messages"); } - if (SerializedAdditionalRawData != null) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - RunTruncationStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunTruncationStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunTruncationStrategy(document.RootElement, options); + throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support reading '{format}' format."); } - internal static RunTruncationStrategy DeserializeRunTruncationStrategy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunTruncationStrategy(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static RunTruncationStrategy DeserializeRunTruncationStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalTruncationObjectType type = default; + int? lastMessages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - return null; + type = new InternalTruncationObjectType(property.Value.GetString()); + continue; } - InternalTruncationObjectType type = default; - int? lastMessages = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("last_messages"u8)) { - if (property.NameEquals("type"u8)) - { - type = new InternalTruncationObjectType(property.Value.GetString()); - continue; - } - if (property.NameEquals("last_messages"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastMessages = null; - continue; - } - lastMessages = property.Value.GetInt32(); + lastMessages = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + lastMessages = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new RunTruncationStrategy(type, lastMessages, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new RunTruncationStrategy(type, lastMessages, serializedAdditionalRawData); + } - RunTruncationStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunTruncationStrategy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + RunTruncationStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static RunTruncationStrategy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRunTruncationStrategy(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunTruncationStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunTruncationStrategy)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static RunTruncationStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunTruncationStrategy(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/RunTruncationStrategy.cs b/src/Generated/Models/RunTruncationStrategy.cs index 3fb0b2da..cdae1c36 100644 --- a/src/Generated/Models/RunTruncationStrategy.cs +++ b/src/Generated/Models/RunTruncationStrategy.cs @@ -5,19 +5,18 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class RunTruncationStrategy { - public partial class RunTruncationStrategy + internal RunTruncationStrategy(InternalTruncationObjectType type, int? lastMessages, IDictionary serializedAdditionalRawData) { - internal RunTruncationStrategy(InternalTruncationObjectType type, int? lastMessages, IDictionary serializedAdditionalRawData) - { - _type = type; - LastMessages = lastMessages; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + _type = type; + LastMessages = lastMessages; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal RunTruncationStrategy() - { - } + internal RunTruncationStrategy() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/SpeechGenerationOptions.Serialization.cs b/src/Generated/Models/SpeechGenerationOptions.Serialization.cs index 823b6165..09822379 100644 --- a/src/Generated/Models/SpeechGenerationOptions.Serialization.cs +++ b/src/Generated/Models/SpeechGenerationOptions.Serialization.cs @@ -8,184 +8,183 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class SpeechGenerationOptions : IJsonModel { - public partial class SpeechGenerationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("model") != true) - { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("input") != true) - { - writer.WritePropertyName("input"u8); - writer.WriteStringValue(Input); - } - if (SerializedAdditionalRawData?.ContainsKey("voice") != true) - { - writer.WritePropertyName("voice"u8); - writer.WriteStringValue(Voice.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) - { - writer.WritePropertyName("response_format"u8); - writer.WriteStringValue(ResponseFormat.Value.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("speed") != true && Optional.IsDefined(SpeedRatio)) - { - writer.WritePropertyName("speed"u8); - writer.WriteNumberValue(SpeedRatio.Value); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("input") != true) + { + writer.WritePropertyName("input"u8); + writer.WriteStringValue(Input); + } + if (SerializedAdditionalRawData?.ContainsKey("voice") != true) + { + writer.WritePropertyName("voice"u8); + writer.WriteStringValue(Voice.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true && Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("speed") != true && Optional.IsDefined(SpeedRatio)) + { + writer.WritePropertyName("speed"u8); + writer.WriteNumberValue(SpeedRatio.Value); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - SpeechGenerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + SpeechGenerationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSpeechGenerationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support reading '{format}' format."); } - internal static SpeechGenerationOptions DeserializeSpeechGenerationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSpeechGenerationOptions(document.RootElement, options); + } + + internal static SpeechGenerationOptions DeserializeSpeechGenerationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateSpeechRequestModel model = default; + string input = default; + GeneratedSpeechVoice voice = default; + GeneratedSpeechFormat? responseFormat = default; + float? speed = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("model"u8)) { - return null; + model = new InternalCreateSpeechRequestModel(property.Value.GetString()); + continue; } - InternalCreateSpeechRequestModel model = default; - string input = default; - GeneratedSpeechVoice voice = default; - GeneratedSpeechFormat? responseFormat = default; - float? speed = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("input"u8)) { - if (property.NameEquals("model"u8)) - { - model = new InternalCreateSpeechRequestModel(property.Value.GetString()); - continue; - } - if (property.NameEquals("input"u8)) - { - input = property.Value.GetString(); - continue; - } - if (property.NameEquals("voice"u8)) - { - voice = new GeneratedSpeechVoice(property.Value.GetString()); - continue; - } - if (property.NameEquals("response_format"u8)) + input = property.Value.GetString(); + continue; + } + if (property.NameEquals("voice"u8)) + { + voice = new GeneratedSpeechVoice(property.Value.GetString()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - responseFormat = new GeneratedSpeechFormat(property.Value.GetString()); continue; } - if (property.NameEquals("speed"u8)) + responseFormat = new GeneratedSpeechFormat(property.Value.GetString()); + continue; + } + if (property.NameEquals("speed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - speed = property.Value.GetSingle(); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + speed = property.Value.GetSingle(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new SpeechGenerationOptions( - model, - input, - voice, - responseFormat, - speed, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new SpeechGenerationOptions( + model, + input, + voice, + responseFormat, + speed, + serializedAdditionalRawData); + } - SpeechGenerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeSpeechGenerationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + SpeechGenerationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static SpeechGenerationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeSpeechGenerationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSpeechGenerationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SpeechGenerationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static SpeechGenerationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSpeechGenerationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/SpeechGenerationOptions.cs b/src/Generated/Models/SpeechGenerationOptions.cs index 8ecda5dc..1dd0ebeb 100644 --- a/src/Generated/Models/SpeechGenerationOptions.cs +++ b/src/Generated/Models/SpeechGenerationOptions.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial class SpeechGenerationOptions { - public partial class SpeechGenerationOptions - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal SpeechGenerationOptions(InternalCreateSpeechRequestModel model, string input, GeneratedSpeechVoice voice, GeneratedSpeechFormat? responseFormat, float? speedRatio, IDictionary serializedAdditionalRawData) - { - Model = model; - Input = input; - Voice = voice; - ResponseFormat = responseFormat; - SpeedRatio = speedRatio; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public GeneratedSpeechFormat? ResponseFormat { get; set; } + internal SpeechGenerationOptions(InternalCreateSpeechRequestModel model, string input, GeneratedSpeechVoice voice, GeneratedSpeechFormat? responseFormat, float? speedRatio, IDictionary serializedAdditionalRawData) + { + Model = model; + Input = input; + Voice = voice; + ResponseFormat = responseFormat; + SpeedRatio = speedRatio; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public GeneratedSpeechFormat? ResponseFormat { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/StaticFileChunkingStrategy.Serialization.cs b/src/Generated/Models/StaticFileChunkingStrategy.Serialization.cs index 94b1916a..045543e8 100644 --- a/src/Generated/Models/StaticFileChunkingStrategy.Serialization.cs +++ b/src/Generated/Models/StaticFileChunkingStrategy.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class StaticFileChunkingStrategy : IJsonModel { - public partial class StaticFileChunkingStrategy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("static") != true) - { - writer.WritePropertyName("static"u8); - writer.WriteObjectValue(_internalDetails, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("static") != true) + { + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(_internalDetails, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - StaticFileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + StaticFileChunkingStrategy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeStaticFileChunkingStrategy(document.RootElement, options); + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support reading '{format}' format."); } - internal static StaticFileChunkingStrategy DeserializeStaticFileChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStaticFileChunkingStrategy(document.RootElement, options); + } + + internal static StaticFileChunkingStrategy DeserializeStaticFileChunkingStrategy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalStaticChunkingStrategyDetails @static = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) { - return null; + @static = InternalStaticChunkingStrategyDetails.DeserializeInternalStaticChunkingStrategyDetails(property.Value, options); + continue; } - InternalStaticChunkingStrategyDetails @static = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("static"u8)) - { - @static = InternalStaticChunkingStrategyDetails.DeserializeInternalStaticChunkingStrategyDetails(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new StaticFileChunkingStrategy(type, serializedAdditionalRawData, @static); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new StaticFileChunkingStrategy(type, serializedAdditionalRawData, @static); + } - StaticFileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeStaticFileChunkingStrategy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + StaticFileChunkingStrategy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new StaticFileChunkingStrategy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeStaticFileChunkingStrategy(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStaticFileChunkingStrategy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StaticFileChunkingStrategy)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new StaticFileChunkingStrategy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeStaticFileChunkingStrategy(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/StaticFileChunkingStrategy.cs b/src/Generated/Models/StaticFileChunkingStrategy.cs index a86690ab..623888e5 100644 --- a/src/Generated/Models/StaticFileChunkingStrategy.cs +++ b/src/Generated/Models/StaticFileChunkingStrategy.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class StaticFileChunkingStrategy : FileChunkingStrategy { - public partial class StaticFileChunkingStrategy : FileChunkingStrategy + internal StaticFileChunkingStrategy(string type, IDictionary serializedAdditionalRawData, InternalStaticChunkingStrategyDetails internalDetails) : base(type, serializedAdditionalRawData) { - internal StaticFileChunkingStrategy(string type, IDictionary serializedAdditionalRawData, InternalStaticChunkingStrategyDetails internalDetails) : base(type, serializedAdditionalRawData) - { - _internalDetails = internalDetails; - } + _internalDetails = internalDetails; + } - internal StaticFileChunkingStrategy() - { - } + internal StaticFileChunkingStrategy() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs b/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs index 6a39741d..c4901055 100644 --- a/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs +++ b/src/Generated/Models/StreamingChatCompletionUpdate.Serialization.cs @@ -8,238 +8,237 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class StreamingChatCompletionUpdate : IJsonModel { - public partial class StreamingChatCompletionUpdate : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("choices") != true) + { + writer.WritePropertyName("choices"u8); + writer.WriteStartArray(); + foreach (var item in Choices) { - writer.WritePropertyName("choices"u8); - writer.WriteStartArray(); - foreach (var item in Choices) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("created") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("created") != true) + { + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("service_tier") != true && Optional.IsDefined(ServiceTier)) + { + if (ServiceTier != null) { - writer.WritePropertyName("created"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("service_tier"u8); + writer.WriteStringValue(ServiceTier.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + else { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); + writer.WriteNull("service_tier"); } - if (SerializedAdditionalRawData?.ContainsKey("service_tier") != true && Optional.IsDefined(ServiceTier)) + } + if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) + { + writer.WritePropertyName("system_fingerprint"u8); + writer.WriteStringValue(SystemFingerprint); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (ServiceTier != null) - { - writer.WritePropertyName("service_tier"u8); - writer.WriteStringValue(ServiceTier.Value.ToString()); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("service_tier"); + continue; } - } - if (SerializedAdditionalRawData?.ContainsKey("system_fingerprint") != true && Optional.IsDefined(SystemFingerprint)) - { - writer.WritePropertyName("system_fingerprint"u8); - writer.WriteStringValue(SystemFingerprint); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("usage") != true && Optional.IsDefined(Usage)) - { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - StreamingChatCompletionUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + StreamingChatCompletionUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeStreamingChatCompletionUpdate(document.RootElement, options); + throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support reading '{format}' format."); } - internal static StreamingChatCompletionUpdate DeserializeStreamingChatCompletionUpdate(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingChatCompletionUpdate(document.RootElement, options); + } + + internal static StreamingChatCompletionUpdate DeserializeStreamingChatCompletionUpdate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IReadOnlyList choices = default; + DateTimeOffset created = default; + string model = default; + InternalCreateChatCompletionStreamResponseServiceTier? serviceTier = default; + string systemFingerprint = default; + InternalCreateChatCompletionStreamResponseObject @object = default; + ChatTokenUsage usage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - IReadOnlyList choices = default; - DateTimeOffset created = default; - string model = default; - InternalCreateChatCompletionStreamResponseServiceTier? serviceTier = default; - string systemFingerprint = default; - InternalCreateChatCompletionStreamResponseObject @object = default; - ChatTokenUsage usage = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("choices"u8)) { - if (property.NameEquals("id"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("choices"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(InternalCreateChatCompletionStreamResponseChoice.DeserializeInternalCreateChatCompletionStreamResponseChoice(item, options)); - } - choices = array; - continue; - } - if (property.NameEquals("created"u8)) - { - created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("model"u8)) - { - model = property.Value.GetString(); - continue; - } - if (property.NameEquals("service_tier"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - serviceTier = null; - continue; - } - serviceTier = new InternalCreateChatCompletionStreamResponseServiceTier(property.Value.GetString()); - continue; + array.Add(InternalCreateChatCompletionStreamResponseChoice.DeserializeInternalCreateChatCompletionStreamResponseChoice(item, options)); } - if (property.NameEquals("system_fingerprint"u8)) - { - systemFingerprint = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) + choices = array; + continue; + } + if (property.NameEquals("created"u8)) + { + created = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("service_tier"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - @object = new InternalCreateChatCompletionStreamResponseObject(property.Value.GetString()); + serviceTier = null; continue; } - if (property.NameEquals("usage"u8)) + serviceTier = new InternalCreateChatCompletionStreamResponseServiceTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("system_fingerprint"u8)) + { + systemFingerprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalCreateChatCompletionStreamResponseObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + usage = ChatTokenUsage.DeserializeChatTokenUsage(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new StreamingChatCompletionUpdate( - id, - choices, - created, - model, - serviceTier, - systemFingerprint, - @object, - usage, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new StreamingChatCompletionUpdate( + id, + choices, + created, + model, + serviceTier, + systemFingerprint, + @object, + usage, + serializedAdditionalRawData); + } - StreamingChatCompletionUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeStreamingChatCompletionUpdate(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + StreamingChatCompletionUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static StreamingChatCompletionUpdate FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeStreamingChatCompletionUpdate(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStreamingChatCompletionUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingChatCompletionUpdate)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static StreamingChatCompletionUpdate FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeStreamingChatCompletionUpdate(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/StreamingChatCompletionUpdate.cs b/src/Generated/Models/StreamingChatCompletionUpdate.cs index b7227902..a2a3e33b 100644 --- a/src/Generated/Models/StreamingChatCompletionUpdate.cs +++ b/src/Generated/Models/StreamingChatCompletionUpdate.cs @@ -6,42 +6,41 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class StreamingChatCompletionUpdate { - public partial class StreamingChatCompletionUpdate + internal IDictionary SerializedAdditionalRawData { get; set; } + internal StreamingChatCompletionUpdate(string id, IEnumerable choices, DateTimeOffset createdAt, string model) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(choices, nameof(choices)); + Argument.AssertNotNull(model, nameof(model)); + + Id = id; + Choices = choices.ToList(); + CreatedAt = createdAt; + Model = model; + } + + internal StreamingChatCompletionUpdate(string id, IReadOnlyList choices, DateTimeOffset createdAt, string model, InternalCreateChatCompletionStreamResponseServiceTier? serviceTier, string systemFingerprint, InternalCreateChatCompletionStreamResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal StreamingChatCompletionUpdate(string id, IEnumerable choices, DateTimeOffset createdAt, string model) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(choices, nameof(choices)); - Argument.AssertNotNull(model, nameof(model)); - - Id = id; - Choices = choices.ToList(); - CreatedAt = createdAt; - Model = model; - } - - internal StreamingChatCompletionUpdate(string id, IReadOnlyList choices, DateTimeOffset createdAt, string model, InternalCreateChatCompletionStreamResponseServiceTier? serviceTier, string systemFingerprint, InternalCreateChatCompletionStreamResponseObject @object, ChatTokenUsage usage, IDictionary serializedAdditionalRawData) - { - Id = id; - Choices = choices; - CreatedAt = createdAt; - Model = model; - ServiceTier = serviceTier; - SystemFingerprint = systemFingerprint; - Object = @object; - Usage = usage; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal StreamingChatCompletionUpdate() - { - } - - public string Id { get; } - public string Model { get; } - public string SystemFingerprint { get; } + Id = id; + Choices = choices; + CreatedAt = createdAt; + Model = model; + ServiceTier = serviceTier; + SystemFingerprint = systemFingerprint; + Object = @object; + Usage = usage; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal StreamingChatCompletionUpdate() + { + } + + public string Id { get; } + public string Model { get; } + public string SystemFingerprint { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/StreamingChatFunctionCallUpdate.Serialization.cs b/src/Generated/Models/StreamingChatFunctionCallUpdate.Serialization.cs index 8a47d0a0..4826dc9a 100644 --- a/src/Generated/Models/StreamingChatFunctionCallUpdate.Serialization.cs +++ b/src/Generated/Models/StreamingChatFunctionCallUpdate.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class StreamingChatFunctionCallUpdate : IJsonModel { - public partial class StreamingChatFunctionCallUpdate : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("arguments") != true && Optional.IsDefined(FunctionArgumentsUpdate)) - { - writer.WritePropertyName("arguments"u8); - writer.WriteStringValue(FunctionArgumentsUpdate); - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(FunctionName)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(FunctionName); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("arguments") != true && Optional.IsDefined(FunctionArgumentsUpdate)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(FunctionArgumentsUpdate); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(FunctionName)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(FunctionName); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - StreamingChatFunctionCallUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + StreamingChatFunctionCallUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeStreamingChatFunctionCallUpdate(document.RootElement, options); + throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support reading '{format}' format."); } - internal static StreamingChatFunctionCallUpdate DeserializeStreamingChatFunctionCallUpdate(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingChatFunctionCallUpdate(document.RootElement, options); + } + + internal static StreamingChatFunctionCallUpdate DeserializeStreamingChatFunctionCallUpdate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string arguments = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("arguments"u8)) { - return null; + arguments = property.Value.GetString(); + continue; } - string arguments = default; - string name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("name"u8)) { - if (property.NameEquals("arguments"u8)) - { - arguments = property.Value.GetString(); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + name = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new StreamingChatFunctionCallUpdate(arguments, name, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new StreamingChatFunctionCallUpdate(arguments, name, serializedAdditionalRawData); + } - StreamingChatFunctionCallUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeStreamingChatFunctionCallUpdate(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + StreamingChatFunctionCallUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static StreamingChatFunctionCallUpdate FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeStreamingChatFunctionCallUpdate(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStreamingChatFunctionCallUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingChatFunctionCallUpdate)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static StreamingChatFunctionCallUpdate FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeStreamingChatFunctionCallUpdate(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/StreamingChatFunctionCallUpdate.cs b/src/Generated/Models/StreamingChatFunctionCallUpdate.cs index cdf403d4..50a3a1cd 100644 --- a/src/Generated/Models/StreamingChatFunctionCallUpdate.cs +++ b/src/Generated/Models/StreamingChatFunctionCallUpdate.cs @@ -5,20 +5,19 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class StreamingChatFunctionCallUpdate { - public partial class StreamingChatFunctionCallUpdate + internal IDictionary SerializedAdditionalRawData { get; set; } + internal StreamingChatFunctionCallUpdate() { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal StreamingChatFunctionCallUpdate() - { - } + } - internal StreamingChatFunctionCallUpdate(string functionArgumentsUpdate, string functionName, IDictionary serializedAdditionalRawData) - { - FunctionArgumentsUpdate = functionArgumentsUpdate; - FunctionName = functionName; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal StreamingChatFunctionCallUpdate(string functionArgumentsUpdate, string functionName, IDictionary serializedAdditionalRawData) + { + FunctionArgumentsUpdate = functionArgumentsUpdate; + FunctionName = functionName; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/StreamingChatToolCallUpdate.Serialization.cs b/src/Generated/Models/StreamingChatToolCallUpdate.Serialization.cs index 123891d2..c9b5ea79 100644 --- a/src/Generated/Models/StreamingChatToolCallUpdate.Serialization.cs +++ b/src/Generated/Models/StreamingChatToolCallUpdate.Serialization.cs @@ -8,167 +8,166 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class StreamingChatToolCallUpdate : IJsonModel { - public partial class StreamingChatToolCallUpdate : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Kind.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("function") != true && Optional.IsDefined(Function)) - { - writer.WritePropertyName("function"u8); - writer.WriteObjectValue(Function, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("index") != true) + { + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + if (SerializedAdditionalRawData?.ContainsKey("id") != true && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Kind.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("function") != true && Optional.IsDefined(Function)) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - StreamingChatToolCallUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + StreamingChatToolCallUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeStreamingChatToolCallUpdate(document.RootElement, options); + throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support reading '{format}' format."); } - internal static StreamingChatToolCallUpdate DeserializeStreamingChatToolCallUpdate(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStreamingChatToolCallUpdate(document.RootElement, options); + } + + internal static StreamingChatToolCallUpdate DeserializeStreamingChatToolCallUpdate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string id = default; + ChatToolCallKind type = default; + InternalChatCompletionMessageToolCallChunkFunction function = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) { - return null; + index = property.Value.GetInt32(); + continue; } - int index = default; - string id = default; - ChatToolCallKind type = default; - InternalChatCompletionMessageToolCallChunkFunction function = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("id"u8)) { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - type = new ChatToolCallKind(property.Value.GetString()); continue; } - if (property.NameEquals("function"u8)) + type = new ChatToolCallKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("function"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - function = InternalChatCompletionMessageToolCallChunkFunction.DeserializeInternalChatCompletionMessageToolCallChunkFunction(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + function = InternalChatCompletionMessageToolCallChunkFunction.DeserializeInternalChatCompletionMessageToolCallChunkFunction(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new StreamingChatToolCallUpdate(index, id, type, function, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new StreamingChatToolCallUpdate(index, id, type, function, serializedAdditionalRawData); + } - StreamingChatToolCallUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeStreamingChatToolCallUpdate(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + StreamingChatToolCallUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static StreamingChatToolCallUpdate FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeStreamingChatToolCallUpdate(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStreamingChatToolCallUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StreamingChatToolCallUpdate)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static StreamingChatToolCallUpdate FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeStreamingChatToolCallUpdate(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/StreamingChatToolCallUpdate.cs b/src/Generated/Models/StreamingChatToolCallUpdate.cs index 5d606fc1..929b20d8 100644 --- a/src/Generated/Models/StreamingChatToolCallUpdate.cs +++ b/src/Generated/Models/StreamingChatToolCallUpdate.cs @@ -5,26 +5,25 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat -{ - public partial class StreamingChatToolCallUpdate - { - internal IDictionary SerializedAdditionalRawData { get; set; } +namespace OpenAI.Chat; - internal StreamingChatToolCallUpdate(int index, string id, ChatToolCallKind kind, InternalChatCompletionMessageToolCallChunkFunction function, IDictionary serializedAdditionalRawData) - { - Index = index; - Id = id; - Kind = kind; - Function = function; - SerializedAdditionalRawData = serializedAdditionalRawData; - } +public partial class StreamingChatToolCallUpdate +{ + internal IDictionary SerializedAdditionalRawData { get; set; } - internal StreamingChatToolCallUpdate() - { - } + internal StreamingChatToolCallUpdate(int index, string id, ChatToolCallKind kind, InternalChatCompletionMessageToolCallChunkFunction function, IDictionary serializedAdditionalRawData) + { + Index = index; + Id = id; + Kind = kind; + Function = function; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int Index { get; } - public string Id { get; } + internal StreamingChatToolCallUpdate() + { } -} + + public int Index { get; } + public string Id { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/SystemChatMessage.Serialization.cs b/src/Generated/Models/SystemChatMessage.Serialization.cs index 71a6676c..fe3c0cd5 100644 --- a/src/Generated/Models/SystemChatMessage.Serialization.cs +++ b/src/Generated/Models/SystemChatMessage.Serialization.cs @@ -8,102 +8,101 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class SystemChatMessage : IJsonModel { - public partial class SystemChatMessage : IJsonModel + SystemChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - SystemChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(SystemChatMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeSystemChatMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(SystemChatMessage)} does not support reading '{format}' format."); } - internal static SystemChatMessage DeserializeSystemChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSystemChatMessage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static SystemChatMessage DeserializeSystemChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ChatMessageRole role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - ChatMessageRole role = default; - IList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("role"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("role"u8)) - { - role = property.Value.GetString().ToChatMessageRole(); - continue; - } - if (property.NameEquals("content"u8)) - { - DeserializeContentValue(property, ref content); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + role = property.Value.GetString().ToChatMessageRole(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new SystemChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, name); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("content"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(SystemChatMessage)} does not support writing '{options.Format}' format."); + DeserializeContentValue(property, ref content); + continue; } - } - - SystemChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeSystemChatMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(SystemChatMessage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new SystemChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, name); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new SystemChatMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeSystemChatMessage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SystemChatMessage)} does not support writing '{options.Format}' format."); } + } + + SystemChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSystemChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SystemChatMessage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new SystemChatMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSystemChatMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/SystemChatMessage.cs b/src/Generated/Models/SystemChatMessage.cs index 962eee34..5f6823d9 100644 --- a/src/Generated/Models/SystemChatMessage.cs +++ b/src/Generated/Models/SystemChatMessage.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class SystemChatMessage : ChatMessage { - public partial class SystemChatMessage : ChatMessage + internal SystemChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string participantName) : base(role, content, serializedAdditionalRawData) { - internal SystemChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string participantName) : base(role, content, serializedAdditionalRawData) - { - ParticipantName = participantName; - } + ParticipantName = participantName; + } - internal SystemChatMessage() - { - } + internal SystemChatMessage() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadCreationOptions.Serialization.cs b/src/Generated/Models/ThreadCreationOptions.Serialization.cs index a415df84..8eff5887 100644 --- a/src/Generated/Models/ThreadCreationOptions.Serialization.cs +++ b/src/Generated/Models/ThreadCreationOptions.Serialization.cs @@ -8,196 +8,195 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadCreationOptions : IJsonModel { - public partial class ThreadCreationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("messages") != true && Optional.IsCollectionDefined(InternalMessages)) + { + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in InternalMessages) { - throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support writing '{format}' format."); + writer.WriteObjectValue(item, options); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("messages") != true && Optional.IsCollectionDefined(InternalMessages)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) { - writer.WritePropertyName("messages"u8); - writer.WriteStartArray(); - foreach (var item in InternalMessages) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); } - if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + else { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } + writer.WriteNull("tool_resources"); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("metadata"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("metadata"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ThreadCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ThreadCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadCreationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support reading '{format}' format."); } - internal static ThreadCreationOptions DeserializeThreadCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadCreationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList messages = default; - ToolResources toolResources = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static ThreadCreationOptions DeserializeThreadCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList messages = default; + ToolResources toolResources = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) { - if (property.NameEquals("messages"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageCreationOptions.DeserializeMessageCreationOptions(item, options)); - } - messages = array; continue; } - if (property.NameEquals("tool_resources"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageCreationOptions.DeserializeMessageCreationOptions(item, options)); + } + messages = array; + continue; + } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + toolResources = null; continue; } - if (property.NameEquals("metadata"u8)) + toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadCreationOptions(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadCreationOptions(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - ThreadCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeThreadCreationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ThreadCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ThreadCreationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeThreadCreationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeThreadCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadCreationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ThreadCreationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeThreadCreationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadCreationOptions.cs b/src/Generated/Models/ThreadCreationOptions.cs index 450cf612..51d98e0a 100644 --- a/src/Generated/Models/ThreadCreationOptions.cs +++ b/src/Generated/Models/ThreadCreationOptions.cs @@ -5,24 +5,23 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadCreationOptions { - public partial class ThreadCreationOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public ThreadCreationOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public ThreadCreationOptions() - { - InternalMessages = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } + InternalMessages = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } - internal ThreadCreationOptions(IList internalMessages, ToolResources toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - InternalMessages = internalMessages; - ToolResources = toolResources; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public IDictionary Metadata { get; set; } + internal ThreadCreationOptions(IList internalMessages, ToolResources toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + InternalMessages = internalMessages; + ToolResources = toolResources; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public IDictionary Metadata { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadDeletionResult.Serialization.cs b/src/Generated/Models/ThreadDeletionResult.Serialization.cs index ed9dba9f..538ab936 100644 --- a/src/Generated/Models/ThreadDeletionResult.Serialization.cs +++ b/src/Generated/Models/ThreadDeletionResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadDeletionResult : IJsonModel { - public partial class ThreadDeletionResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(ThreadId); - } - if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) - { - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(ThreadId); + } + if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) + { + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ThreadDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ThreadDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadDeletionResult(document.RootElement, options); + throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support reading '{format}' format."); } - internal static ThreadDeletionResult DeserializeThreadDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadDeletionResult(document.RootElement, options); + } + + internal static ThreadDeletionResult DeserializeThreadDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalDeleteThreadResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - bool deleted = default; - InternalDeleteThreadResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("deleted"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalDeleteThreadResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + deleted = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadDeletionResult(id, deleted, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support writing '{options.Format}' format."); + @object = new InternalDeleteThreadResponseObject(property.Value.GetString()); + continue; } - } - - ThreadDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeThreadDeletionResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadDeletionResult(id, deleted, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ThreadDeletionResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeThreadDeletionResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support writing '{options.Format}' format."); } + } + + ThreadDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeThreadDeletionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadDeletionResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ThreadDeletionResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeThreadDeletionResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadDeletionResult.cs b/src/Generated/Models/ThreadDeletionResult.cs index d0b06a68..2558a8e5 100644 --- a/src/Generated/Models/ThreadDeletionResult.cs +++ b/src/Generated/Models/ThreadDeletionResult.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadDeletionResult { - public partial class ThreadDeletionResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ThreadDeletionResult(string threadId, bool deleted) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ThreadDeletionResult(string threadId, bool deleted) - { - Argument.AssertNotNull(threadId, nameof(threadId)); + Argument.AssertNotNull(threadId, nameof(threadId)); - ThreadId = threadId; - Deleted = deleted; - } + ThreadId = threadId; + Deleted = deleted; + } - internal ThreadDeletionResult(string threadId, bool deleted, InternalDeleteThreadResponseObject @object, IDictionary serializedAdditionalRawData) - { - ThreadId = threadId; - Deleted = deleted; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ThreadDeletionResult(string threadId, bool deleted, InternalDeleteThreadResponseObject @object, IDictionary serializedAdditionalRawData) + { + ThreadId = threadId; + Deleted = deleted; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ThreadDeletionResult() - { - } - public bool Deleted { get; } + internal ThreadDeletionResult() + { } -} + public bool Deleted { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadMessage.Serialization.cs b/src/Generated/Models/ThreadMessage.Serialization.cs index 33321390..1b567fa7 100644 --- a/src/Generated/Models/ThreadMessage.Serialization.cs +++ b/src/Generated/Models/ThreadMessage.Serialization.cs @@ -8,399 +8,398 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadMessage : IJsonModel { - public partial class ThreadMessage : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadMessage)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("thread_id") != true) + { + writer.WritePropertyName("thread_id"u8); + writer.WriteStringValue(ThreadId); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("incomplete_details") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (IncompleteDetails != null) { - throw new FormatException($"The model {nameof(ThreadMessage)} does not support writing '{format}' format."); + writer.WritePropertyName("incomplete_details"u8); + writer.WriteObjectValue(IncompleteDetails, options); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + else { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WriteNull("incomplete_details"); } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true) + { + if (CompletedAt != null) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + else { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WriteNull("completed_at"); } - if (SerializedAdditionalRawData?.ContainsKey("thread_id") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("incomplete_at") != true) + { + if (IncompleteAt != null) { - writer.WritePropertyName("thread_id"u8); - writer.WriteStringValue(ThreadId); + writer.WritePropertyName("incomplete_at"u8); + writer.WriteNumberValue(IncompleteAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + else { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); + writer.WriteNull("incomplete_at"); } - if (SerializedAdditionalRawData?.ContainsKey("incomplete_details") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("role") != true) + { + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("content") != true) + { + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) { - if (IncompleteDetails != null) - { - writer.WritePropertyName("incomplete_details"u8); - writer.WriteObjectValue(IncompleteDetails, options); - } - else - { - writer.WriteNull("incomplete_details"); - } + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + { + if (AssistantId != null) { - if (CompletedAt != null) - { - writer.WritePropertyName("completed_at"u8); - writer.WriteNumberValue(CompletedAt.Value, "U"); - } - else - { - writer.WriteNull("completed_at"); - } + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); } - if (SerializedAdditionalRawData?.ContainsKey("incomplete_at") != true) + else { - if (IncompleteAt != null) - { - writer.WritePropertyName("incomplete_at"u8); - writer.WriteNumberValue(IncompleteAt.Value, "U"); - } - else - { - writer.WriteNull("incomplete_at"); - } + writer.WriteNull("assistant_id"); } - if (SerializedAdditionalRawData?.ContainsKey("role") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("run_id") != true) + { + if (RunId != null) { - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToSerialString()); + writer.WritePropertyName("run_id"u8); + writer.WriteStringValue(RunId); } - if (SerializedAdditionalRawData?.ContainsKey("content") != true) + else { - writer.WritePropertyName("content"u8); + writer.WriteNull("run_id"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("attachments") != true) + { + if (Attachments != null && Optional.IsCollectionDefined(Attachments)) + { + writer.WritePropertyName("attachments"u8); writer.WriteStartArray(); - foreach (var item in Content) + foreach (var item in Attachments) { - writer.WriteObjectValue(item, options); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + else { - if (AssistantId != null) - { - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); - } - else - { - writer.WriteNull("assistant_id"); - } + writer.WriteNull("attachments"); } - if (SerializedAdditionalRawData?.ContainsKey("run_id") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + { + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { - if (RunId != null) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("run_id"u8); - writer.WriteStringValue(RunId); - } - else - { - writer.WriteNull("run_id"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("attachments") != true) + else { - if (Attachments != null && Optional.IsCollectionDefined(Attachments)) - { - writer.WritePropertyName("attachments"u8); - writer.WriteStartArray(); - foreach (var item in Attachments) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - else - { - writer.WriteNull("attachments"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ThreadMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ThreadMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ThreadMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(ThreadMessage)} does not support reading '{format}' format."); } - internal static ThreadMessage DeserializeThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadMessage(document.RootElement, options); + } + + internal static ThreadMessage DeserializeThreadMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalMessageObjectObject @object = default; + DateTimeOffset createdAt = default; + string threadId = default; + MessageStatus status = default; + MessageFailureDetails incompleteDetails = default; + DateTimeOffset? completedAt = default; + DateTimeOffset? incompleteAt = default; + MessageRole role = default; + IReadOnlyList content = default; + string assistantId = default; + string runId = default; + IReadOnlyList attachments = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalMessageObjectObject @object = default; - DateTimeOffset createdAt = default; - string threadId = default; - MessageStatus status = default; - MessageFailureDetails incompleteDetails = default; - DateTimeOffset? completedAt = default; - DateTimeOffset? incompleteAt = default; - MessageRole role = default; - IReadOnlyList content = default; - string assistantId = default; - string runId = default; - IReadOnlyList attachments = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalMessageObjectObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("thread_id"u8)) - { - threadId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new MessageStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("incomplete_details"u8)) + @object = new InternalMessageObjectObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("thread_id"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new MessageStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("incomplete_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - incompleteDetails = null; - continue; - } - incompleteDetails = MessageFailureDetails.DeserializeMessageFailureDetails(property.Value, options); + incompleteDetails = null; continue; } - if (property.NameEquals("completed_at"u8)) + incompleteDetails = MessageFailureDetails.DeserializeMessageFailureDetails(property.Value, options); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - completedAt = null; - continue; - } - completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + completedAt = null; continue; } - if (property.NameEquals("incomplete_at"u8)) + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("incomplete_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - incompleteAt = null; - continue; - } - incompleteAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + incompleteAt = null; continue; } - if (property.NameEquals("role"u8)) + incompleteAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("role"u8)) + { + role = property.Value.GetString().ToMessageRole(); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - role = property.Value.GetString().ToMessageRole(); - continue; + array.Add(MessageContent.DeserializeMessageContent(item, options)); } - if (property.NameEquals("content"u8)) + content = array; + continue; + } + if (property.NameEquals("assistant_id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageContent.DeserializeMessageContent(item, options)); - } - content = array; + assistantId = null; continue; } - if (property.NameEquals("assistant_id"u8)) + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("run_id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - assistantId = null; - continue; - } - assistantId = property.Value.GetString(); + runId = null; continue; } - if (property.NameEquals("run_id"u8)) + runId = property.Value.GetString(); + continue; + } + if (property.NameEquals("attachments"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - runId = null; - continue; - } - runId = property.Value.GetString(); + attachments = new ChangeTrackingList(); continue; } - if (property.NameEquals("attachments"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - attachments = new ChangeTrackingList(); - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(MessageCreationAttachment.DeserializeMessageCreationAttachment(item, options)); - } - attachments = array; - continue; + array.Add(MessageCreationAttachment.DeserializeMessageCreationAttachment(item, options)); } - if (property.NameEquals("metadata"u8)) + attachments = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; + metadata = new ChangeTrackingDictionary(); continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadMessage( - id, - @object, - createdAt, - threadId, - status, - incompleteDetails, - completedAt, - incompleteAt, - role, - content, - assistantId, - runId, - attachments, - metadata, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ThreadMessage)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadMessage( + id, + @object, + createdAt, + threadId, + status, + incompleteDetails, + completedAt, + incompleteAt, + role, + content, + assistantId, + runId, + attachments, + metadata, + serializedAdditionalRawData); + } - ThreadMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeThreadMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadMessage)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadMessage)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ThreadMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ThreadMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeThreadMessage(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeThreadMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadMessage)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ThreadMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeThreadMessage(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadMessage.cs b/src/Generated/Models/ThreadMessage.cs index ba5967d5..35e15211 100644 --- a/src/Generated/Models/ThreadMessage.cs +++ b/src/Generated/Models/ThreadMessage.cs @@ -6,66 +6,65 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadMessage { - public partial class ThreadMessage + internal IDictionary SerializedAdditionalRawData { get; set; } + internal ThreadMessage(string id, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageFailureDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IEnumerable content, string assistantId, string runId, IEnumerable attachments, IReadOnlyDictionary metadata) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal ThreadMessage(string id, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageFailureDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IEnumerable content, string assistantId, string runId, IEnumerable attachments, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); - Id = id; - CreatedAt = createdAt; - ThreadId = threadId; - Status = status; - IncompleteDetails = incompleteDetails; - CompletedAt = completedAt; - IncompleteAt = incompleteAt; - Role = role; - Content = content.ToList(); - AssistantId = assistantId; - RunId = runId; - Attachments = attachments?.ToList(); - Metadata = metadata; - } + Id = id; + CreatedAt = createdAt; + ThreadId = threadId; + Status = status; + IncompleteDetails = incompleteDetails; + CompletedAt = completedAt; + IncompleteAt = incompleteAt; + Role = role; + Content = content.ToList(); + AssistantId = assistantId; + RunId = runId; + Attachments = attachments?.ToList(); + Metadata = metadata; + } - internal ThreadMessage(string id, InternalMessageObjectObject @object, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageFailureDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IReadOnlyList content, string assistantId, string runId, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - ThreadId = threadId; - Status = status; - IncompleteDetails = incompleteDetails; - CompletedAt = completedAt; - IncompleteAt = incompleteAt; - Role = role; - Content = content; - AssistantId = assistantId; - RunId = runId; - Attachments = attachments; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ThreadMessage(string id, InternalMessageObjectObject @object, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageFailureDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IReadOnlyList content, string assistantId, string runId, IReadOnlyList attachments, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + ThreadId = threadId; + Status = status; + IncompleteDetails = incompleteDetails; + CompletedAt = completedAt; + IncompleteAt = incompleteAt; + Role = role; + Content = content; + AssistantId = assistantId; + RunId = runId; + Attachments = attachments; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ThreadMessage() - { - } + internal ThreadMessage() + { + } - public string Id { get; } + public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public string ThreadId { get; } - public MessageStatus Status { get; } - public MessageFailureDetails IncompleteDetails { get; } - public DateTimeOffset? CompletedAt { get; } - public DateTimeOffset? IncompleteAt { get; } - public IReadOnlyList Content { get; } - public string AssistantId { get; } - public string RunId { get; } - public IReadOnlyDictionary Metadata { get; } - } -} + public DateTimeOffset CreatedAt { get; } + public string ThreadId { get; } + public MessageStatus Status { get; } + public MessageFailureDetails IncompleteDetails { get; } + public DateTimeOffset? CompletedAt { get; } + public DateTimeOffset? IncompleteAt { get; } + public IReadOnlyList Content { get; } + public string AssistantId { get; } + public string RunId { get; } + public IReadOnlyDictionary Metadata { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadModificationOptions.Serialization.cs b/src/Generated/Models/ThreadModificationOptions.Serialization.cs index e53955c2..95e2039e 100644 --- a/src/Generated/Models/ThreadModificationOptions.Serialization.cs +++ b/src/Generated/Models/ThreadModificationOptions.Serialization.cs @@ -8,171 +8,170 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadModificationOptions : IJsonModel { - public partial class ThreadModificationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (ToolResources != null) { - throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("tool_resources") != true && Optional.IsDefined(ToolResources)) + else { - if (ToolResources != null) - { - writer.WritePropertyName("tool_resources"u8); - writer.WriteObjectValue(ToolResources, options); - } - else - { - writer.WriteNull("tool_resources"); - } + writer.WriteNull("tool_resources"); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("metadata"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("metadata"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ThreadModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ThreadModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadModificationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support reading '{format}' format."); } - internal static ThreadModificationOptions DeserializeThreadModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadModificationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - ToolResources toolResources = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static ThreadModificationOptions DeserializeThreadModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolResources toolResources = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_resources"u8)) { - if (property.NameEquals("tool_resources"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolResources = null; - continue; - } - toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + toolResources = null; continue; } - if (property.NameEquals("metadata"u8)) + toolResources = Assistants.ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadModificationOptions(toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadModificationOptions(toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - ThreadModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeThreadModificationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ThreadModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ThreadModificationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeThreadModificationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeThreadModificationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadModificationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ThreadModificationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeThreadModificationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadModificationOptions.cs b/src/Generated/Models/ThreadModificationOptions.cs index b26090b1..109a535c 100644 --- a/src/Generated/Models/ThreadModificationOptions.cs +++ b/src/Generated/Models/ThreadModificationOptions.cs @@ -5,22 +5,21 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadModificationOptions { - public partial class ThreadModificationOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public ThreadModificationOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public ThreadModificationOptions() - { - Metadata = new ChangeTrackingDictionary(); - } + Metadata = new ChangeTrackingDictionary(); + } - internal ThreadModificationOptions(ToolResources toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - ToolResources = toolResources; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - public IDictionary Metadata { get; set; } + internal ThreadModificationOptions(ToolResources toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + ToolResources = toolResources; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + public IDictionary Metadata { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadRun.Serialization.cs b/src/Generated/Models/ThreadRun.Serialization.cs index 4c884489..9a981306 100644 --- a/src/Generated/Models/ThreadRun.Serialization.cs +++ b/src/Generated/Models/ThreadRun.Serialization.cs @@ -8,665 +8,664 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadRun : IJsonModel { - public partial class ThreadRun : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(ThreadRun)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("thread_id") != true) + { + writer.WritePropertyName("thread_id"u8); + writer.WriteStringValue(ThreadId); + } + if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + { + writer.WritePropertyName("assistant_id"u8); + writer.WriteStringValue(AssistantId); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("required_action") != true) + { + if (_internalRequiredAction != null) { - throw new FormatException($"The model {nameof(ThreadRun)} does not support writing '{format}' format."); + writer.WritePropertyName("required_action"u8); + writer.WriteObjectValue(_internalRequiredAction, options); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + else { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); + writer.WriteNull("required_action"); } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("last_error") != true) + { + if (LastError != null) { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("last_error"u8); + writer.WriteObjectValue(LastError, options); } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + else { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); + writer.WriteNull("last_error"); } - if (SerializedAdditionalRawData?.ContainsKey("thread_id") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true) + { + if (ExpiresAt != null) { - writer.WritePropertyName("thread_id"u8); - writer.WriteStringValue(ThreadId); + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("assistant_id") != true) + else { - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); + writer.WriteNull("expires_at"); } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("started_at") != true) + { + if (StartedAt != null) { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("started_at"u8); + writer.WriteNumberValue(StartedAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("required_action") != true) + else { - if (_internalRequiredAction != null) - { - writer.WritePropertyName("required_action"u8); - writer.WriteObjectValue(_internalRequiredAction, options); - } - else - { - writer.WriteNull("required_action"); - } + writer.WriteNull("started_at"); } - if (SerializedAdditionalRawData?.ContainsKey("last_error") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("cancelled_at") != true) + { + if (CancelledAt != null) { - if (LastError != null) - { - writer.WritePropertyName("last_error"u8); - writer.WriteObjectValue(LastError, options); - } - else - { - writer.WriteNull("last_error"); - } + writer.WritePropertyName("cancelled_at"u8); + writer.WriteNumberValue(CancelledAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true) + else { - if (ExpiresAt != null) - { - writer.WritePropertyName("expires_at"u8); - writer.WriteNumberValue(ExpiresAt.Value, "U"); - } - else - { - writer.WriteNull("expires_at"); - } + writer.WriteNull("cancelled_at"); } - if (SerializedAdditionalRawData?.ContainsKey("started_at") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("failed_at") != true) + { + if (FailedAt != null) { - if (StartedAt != null) - { - writer.WritePropertyName("started_at"u8); - writer.WriteNumberValue(StartedAt.Value, "U"); - } - else - { - writer.WriteNull("started_at"); - } + writer.WritePropertyName("failed_at"u8); + writer.WriteNumberValue(FailedAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("cancelled_at") != true) + else { - if (CancelledAt != null) - { - writer.WritePropertyName("cancelled_at"u8); - writer.WriteNumberValue(CancelledAt.Value, "U"); - } - else - { - writer.WriteNull("cancelled_at"); - } + writer.WriteNull("failed_at"); } - if (SerializedAdditionalRawData?.ContainsKey("failed_at") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true) + { + if (CompletedAt != null) { - if (FailedAt != null) - { - writer.WritePropertyName("failed_at"u8); - writer.WriteNumberValue(FailedAt.Value, "U"); - } - else - { - writer.WriteNull("failed_at"); - } + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("completed_at") != true) + else { - if (CompletedAt != null) - { - writer.WritePropertyName("completed_at"u8); - writer.WriteNumberValue(CompletedAt.Value, "U"); - } - else - { - writer.WriteNull("completed_at"); - } + writer.WriteNull("completed_at"); } - if (SerializedAdditionalRawData?.ContainsKey("incomplete_details") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("incomplete_details") != true) + { + if (IncompleteDetails != null) { - if (IncompleteDetails != null) - { - writer.WritePropertyName("incomplete_details"u8); - writer.WriteObjectValue(IncompleteDetails, options); - } - else - { - writer.WriteNull("incomplete_details"); - } + writer.WritePropertyName("incomplete_details"u8); + writer.WriteObjectValue(IncompleteDetails, options); } - if (SerializedAdditionalRawData?.ContainsKey("model") != true) + else { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(Model); + writer.WriteNull("incomplete_details"); } - if (SerializedAdditionalRawData?.ContainsKey("instructions") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("model") != true) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (SerializedAdditionalRawData?.ContainsKey("instructions") != true) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + if (SerializedAdditionalRawData?.ContainsKey("tools") != true) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(Instructions); + writer.WriteObjectValue(item, options); } - if (SerializedAdditionalRawData?.ContainsKey("tools") != true) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + { + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in Tools) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteObjectValue(item, options); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } - writer.WriteEndArray(); + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + else { - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else - { - writer.WriteNull("metadata"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("usage") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("usage") != true) + { + if (Usage != null) { - if (Usage != null) - { - writer.WritePropertyName("usage"u8); - writer.WriteObjectValue(Usage, options); - } - else - { - writer.WriteNull("usage"); - } + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + else { - if (Temperature != null) - { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature.Value); - } - else - { - writer.WriteNull("temperature"); - } + writer.WriteNull("usage"); } - if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true && Optional.IsDefined(Temperature)) + { + if (Temperature != null) { - if (NucleusSamplingFactor != null) - { - writer.WritePropertyName("top_p"u8); - writer.WriteNumberValue(NucleusSamplingFactor.Value); - } - else - { - writer.WriteNull("top_p"); - } + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_prompt_tokens") != true) + else { - if (MaxPromptTokens != null) - { - writer.WritePropertyName("max_prompt_tokens"u8); - writer.WriteNumberValue(MaxPromptTokens.Value); - } - else - { - writer.WriteNull("max_prompt_tokens"); - } + writer.WriteNull("temperature"); } - if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("top_p") != true && Optional.IsDefined(NucleusSamplingFactor)) + { + if (NucleusSamplingFactor != null) { - if (MaxCompletionTokens != null) - { - writer.WritePropertyName("max_completion_tokens"u8); - writer.WriteNumberValue(MaxCompletionTokens.Value); - } - else - { - writer.WriteNull("max_completion_tokens"); - } + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(NucleusSamplingFactor.Value); } - if (SerializedAdditionalRawData?.ContainsKey("truncation_strategy") != true) + else { - if (TruncationStrategy != null) - { - writer.WritePropertyName("truncation_strategy"u8); - writer.WriteObjectValue(TruncationStrategy, options); - } - else - { - writer.WriteNull("truncation_strategy"); - } + writer.WriteNull("top_p"); } - if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("max_prompt_tokens") != true) + { + if (MaxPromptTokens != null) { - if (ToolConstraint != null) - { - writer.WritePropertyName("tool_choice"u8); - writer.WriteObjectValue(ToolConstraint, options); - } - else - { - writer.WriteNull("tool_choice"); - } + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); } - if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true) + else { - writer.WritePropertyName("parallel_tool_calls"u8); - writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + writer.WriteNull("max_prompt_tokens"); } - if (SerializedAdditionalRawData?.ContainsKey("response_format") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") != true) + { + if (MaxCompletionTokens != null) { - if (ResponseFormat != null) - { - writer.WritePropertyName("response_format"u8); - writer.WriteObjectValue(ResponseFormat, options); - } - else - { - writer.WriteNull("response_format"); - } + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + writer.WriteNull("max_completion_tokens"); } - writer.WriteEndObject(); } - - ThreadRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + if (SerializedAdditionalRawData?.ContainsKey("truncation_strategy") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + if (TruncationStrategy != null) { - throw new FormatException($"The model {nameof(ThreadRun)} does not support reading '{format}' format."); + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadRun(document.RootElement, options); } - - internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData?.ContainsKey("tool_choice") != true) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string id = default; - InternalRunObjectObject @object = default; - DateTimeOffset createdAt = default; - string threadId = default; - string assistantId = default; - RunStatus status = default; - InternalRunRequiredAction requiredAction = default; - RunError lastError = default; - DateTimeOffset? expiresAt = default; - DateTimeOffset? startedAt = default; - DateTimeOffset? cancelledAt = default; - DateTimeOffset? failedAt = default; - DateTimeOffset? completedAt = default; - RunIncompleteDetails incompleteDetails = default; - string model = default; - string instructions = default; - IReadOnlyList tools = default; - IReadOnlyDictionary metadata = default; - RunTokenUsage usage = default; - float? temperature = default; - float? topP = default; - int? maxPromptTokens = default; - int? maxCompletionTokens = default; - RunTruncationStrategy truncationStrategy = default; - ToolConstraint toolChoice = default; - bool? parallelToolCalls = default; - AssistantResponseFormat responseFormat = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalRunObjectObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("thread_id"u8)) - { - threadId = property.Value.GetString(); - continue; - } - if (property.NameEquals("assistant_id"u8)) - { - assistantId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new RunStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("required_action"u8)) + if (ToolConstraint != null) + { + writer.WritePropertyName("tool_choice"u8); + writer.WriteObjectValue(ToolConstraint, options); + } + else + { + writer.WriteNull("tool_choice"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("parallel_tool_calls") != true) + { + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCallsEnabled.Value); + } + if (SerializedAdditionalRawData?.ContainsKey("response_format") != true) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); + writer.WriteObjectValue(ResponseFormat, options); + } + else + { + writer.WriteNull("response_format"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - requiredAction = null; - continue; - } - requiredAction = InternalRunRequiredAction.DeserializeInternalRunRequiredAction(property.Value, options); continue; } - if (property.NameEquals("last_error"u8)) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastError = null; - continue; - } - lastError = RunError.DeserializeRunError(property.Value, options); - continue; + JsonSerializer.Serialize(writer, document.RootElement); } - if (property.NameEquals("expires_at"u8)) +#endif + } + } + writer.WriteEndObject(); + } + + ThreadRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ThreadRun)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeThreadRun(document.RootElement, options); + } + + internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalRunObjectObject @object = default; + DateTimeOffset createdAt = default; + string threadId = default; + string assistantId = default; + RunStatus status = default; + InternalRunRequiredAction requiredAction = default; + RunError lastError = default; + DateTimeOffset? expiresAt = default; + DateTimeOffset? startedAt = default; + DateTimeOffset? cancelledAt = default; + DateTimeOffset? failedAt = default; + DateTimeOffset? completedAt = default; + RunIncompleteDetails incompleteDetails = default; + string model = default; + string instructions = default; + IReadOnlyList tools = default; + IReadOnlyDictionary metadata = default; + RunTokenUsage usage = default; + float? temperature = default; + float? topP = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + RunTruncationStrategy truncationStrategy = default; + ToolConstraint toolChoice = default; + bool? parallelToolCalls = default; + AssistantResponseFormat responseFormat = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new InternalRunObjectObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("thread_id"u8)) + { + threadId = property.Value.GetString(); + continue; + } + if (property.NameEquals("assistant_id"u8)) + { + assistantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new RunStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("required_action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - expiresAt = null; - continue; - } - expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + requiredAction = null; continue; } - if (property.NameEquals("started_at"u8)) + requiredAction = InternalRunRequiredAction.DeserializeInternalRunRequiredAction(property.Value, options); + continue; + } + if (property.NameEquals("last_error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - startedAt = null; - continue; - } - startedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + lastError = null; continue; } - if (property.NameEquals("cancelled_at"u8)) + lastError = RunError.DeserializeRunError(property.Value, options); + continue; + } + if (property.NameEquals("expires_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - cancelledAt = null; - continue; - } - cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + expiresAt = null; continue; } - if (property.NameEquals("failed_at"u8)) + expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("started_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - failedAt = null; - continue; - } - failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + startedAt = null; continue; } - if (property.NameEquals("completed_at"u8)) + startedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("cancelled_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - completedAt = null; - continue; - } - completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + cancelledAt = null; continue; } - if (property.NameEquals("incomplete_details"u8)) + cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("failed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - incompleteDetails = null; - continue; - } - incompleteDetails = RunIncompleteDetails.DeserializeRunIncompleteDetails(property.Value, options); + failedAt = null; continue; } - if (property.NameEquals("model"u8)) + failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - model = property.Value.GetString(); + completedAt = null; continue; } - if (property.NameEquals("instructions"u8)) + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("incomplete_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - instructions = property.Value.GetString(); + incompleteDetails = null; continue; } - if (property.NameEquals("tools"u8)) + incompleteDetails = RunIncompleteDetails.DeserializeRunIncompleteDetails(property.Value, options); + continue; + } + if (property.NameEquals("model"u8)) + { + model = property.Value.GetString(); + continue; + } + if (property.NameEquals("instructions"u8)) + { + instructions = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); - } - tools = array; - continue; + array.Add(ToolDefinition.DeserializeToolDefinition(item, options)); } - if (property.NameEquals("metadata"u8)) + tools = array; + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; + metadata = new ChangeTrackingDictionary(); continue; } - if (property.NameEquals("usage"u8)) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - usage = null; - continue; - } - usage = RunTokenUsage.DeserializeRunTokenUsage(property.Value, options); - continue; + dictionary.Add(property0.Name, property0.Value.GetString()); } - if (property.NameEquals("temperature"u8)) + metadata = dictionary; + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - temperature = null; - continue; - } - temperature = property.Value.GetSingle(); + usage = null; continue; } - if (property.NameEquals("top_p"u8)) + usage = RunTokenUsage.DeserializeRunTokenUsage(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - topP = null; - continue; - } - topP = property.Value.GetSingle(); + temperature = null; continue; } - if (property.NameEquals("max_prompt_tokens"u8)) + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxPromptTokens = null; - continue; - } - maxPromptTokens = property.Value.GetInt32(); + topP = null; continue; } - if (property.NameEquals("max_completion_tokens"u8)) + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - maxCompletionTokens = null; - continue; - } - maxCompletionTokens = property.Value.GetInt32(); + maxPromptTokens = null; continue; } - if (property.NameEquals("truncation_strategy"u8)) + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - truncationStrategy = null; - continue; - } - truncationStrategy = RunTruncationStrategy.DeserializeRunTruncationStrategy(property.Value, options); + maxCompletionTokens = null; continue; } - if (property.NameEquals("tool_choice"u8)) + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - toolChoice = null; - continue; - } - toolChoice = Assistants.ToolConstraint.DeserializeToolConstraint(property.Value, options); + truncationStrategy = null; continue; } - if (property.NameEquals("parallel_tool_calls"u8)) + truncationStrategy = RunTruncationStrategy.DeserializeRunTruncationStrategy(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - parallelToolCalls = property.Value.GetBoolean(); + toolChoice = null; continue; } - if (property.NameEquals("response_format"u8)) + toolChoice = Assistants.ToolConstraint.DeserializeToolConstraint(property.Value, options); + continue; + } + if (property.NameEquals("parallel_tool_calls"u8)) + { + parallelToolCalls = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - responseFormat = null; - continue; - } - responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + responseFormat = null; continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + responseFormat = AssistantResponseFormat.DeserializeAssistantResponseFormat(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ThreadRun( - id, - @object, - createdAt, - threadId, - assistantId, - status, - requiredAction, - lastError, - expiresAt, - startedAt, - cancelledAt, - failedAt, - completedAt, - incompleteDetails, - model, - instructions, - tools, - metadata, - usage, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - truncationStrategy, - toolChoice, - parallelToolCalls, - responseFormat, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ThreadRun)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ThreadRun( + id, + @object, + createdAt, + threadId, + assistantId, + status, + requiredAction, + lastError, + expiresAt, + startedAt, + cancelledAt, + failedAt, + completedAt, + incompleteDetails, + model, + instructions, + tools, + metadata, + usage, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + parallelToolCalls, + responseFormat, + serializedAdditionalRawData); + } - ThreadRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeThreadRun(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ThreadRun)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ThreadRun)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ThreadRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ThreadRun FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeThreadRun(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeThreadRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ThreadRun)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ThreadRun FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeThreadRun(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ThreadRun.cs b/src/Generated/Models/ThreadRun.cs index cc4a4457..4113ae04 100644 --- a/src/Generated/Models/ThreadRun.cs +++ b/src/Generated/Models/ThreadRun.cs @@ -6,69 +6,68 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ThreadRun { - public partial class ThreadRun - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ThreadRun(string id, InternalRunObjectObject @object, DateTimeOffset createdAt, string threadId, string assistantId, RunStatus status, InternalRunRequiredAction internalRequiredAction, RunError lastError, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, RunIncompleteDetails incompleteDetails, string model, string instructions, IReadOnlyList tools, IReadOnlyDictionary metadata, RunTokenUsage usage, float? temperature, float? nucleusSamplingFactor, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - ThreadId = threadId; - AssistantId = assistantId; - Status = status; - _internalRequiredAction = internalRequiredAction; - LastError = lastError; - ExpiresAt = expiresAt; - StartedAt = startedAt; - CancelledAt = cancelledAt; - FailedAt = failedAt; - CompletedAt = completedAt; - IncompleteDetails = incompleteDetails; - Model = model; - Instructions = instructions; - Tools = tools; - Metadata = metadata; - Usage = usage; - Temperature = temperature; - NucleusSamplingFactor = nucleusSamplingFactor; - MaxPromptTokens = maxPromptTokens; - MaxCompletionTokens = maxCompletionTokens; - TruncationStrategy = truncationStrategy; - ToolConstraint = toolConstraint; - ParallelToolCallsEnabled = parallelToolCallsEnabled; - ResponseFormat = responseFormat; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ThreadRun(string id, InternalRunObjectObject @object, DateTimeOffset createdAt, string threadId, string assistantId, RunStatus status, InternalRunRequiredAction internalRequiredAction, RunError lastError, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, DateTimeOffset? completedAt, RunIncompleteDetails incompleteDetails, string model, string instructions, IReadOnlyList tools, IReadOnlyDictionary metadata, RunTokenUsage usage, float? temperature, float? nucleusSamplingFactor, int? maxPromptTokens, int? maxCompletionTokens, RunTruncationStrategy truncationStrategy, ToolConstraint toolConstraint, bool? parallelToolCallsEnabled, AssistantResponseFormat responseFormat, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + ThreadId = threadId; + AssistantId = assistantId; + Status = status; + _internalRequiredAction = internalRequiredAction; + LastError = lastError; + ExpiresAt = expiresAt; + StartedAt = startedAt; + CancelledAt = cancelledAt; + FailedAt = failedAt; + CompletedAt = completedAt; + IncompleteDetails = incompleteDetails; + Model = model; + Instructions = instructions; + Tools = tools; + Metadata = metadata; + Usage = usage; + Temperature = temperature; + NucleusSamplingFactor = nucleusSamplingFactor; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolConstraint = toolConstraint; + ParallelToolCallsEnabled = parallelToolCallsEnabled; + ResponseFormat = responseFormat; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ThreadRun() - { - } + internal ThreadRun() + { + } - public string Id { get; } + public string Id { get; } - public DateTimeOffset CreatedAt { get; } - public string ThreadId { get; } - public string AssistantId { get; } - public RunStatus Status { get; } - public RunError LastError { get; } - public DateTimeOffset? ExpiresAt { get; } - public DateTimeOffset? StartedAt { get; } - public DateTimeOffset? CancelledAt { get; } - public DateTimeOffset? FailedAt { get; } - public DateTimeOffset? CompletedAt { get; } - public RunIncompleteDetails IncompleteDetails { get; } - public string Model { get; } - public string Instructions { get; } - public IReadOnlyList Tools { get; } - public IReadOnlyDictionary Metadata { get; } - public RunTokenUsage Usage { get; } - public float? Temperature { get; } - public int? MaxPromptTokens { get; } - public int? MaxCompletionTokens { get; } - public RunTruncationStrategy TruncationStrategy { get; } - } -} + public DateTimeOffset CreatedAt { get; } + public string ThreadId { get; } + public string AssistantId { get; } + public RunStatus Status { get; } + public RunError LastError { get; } + public DateTimeOffset? ExpiresAt { get; } + public DateTimeOffset? StartedAt { get; } + public DateTimeOffset? CancelledAt { get; } + public DateTimeOffset? FailedAt { get; } + public DateTimeOffset? CompletedAt { get; } + public RunIncompleteDetails IncompleteDetails { get; } + public string Model { get; } + public string Instructions { get; } + public IReadOnlyList Tools { get; } + public IReadOnlyDictionary Metadata { get; } + public RunTokenUsage Usage { get; } + public float? Temperature { get; } + public int? MaxPromptTokens { get; } + public int? MaxCompletionTokens { get; } + public RunTruncationStrategy TruncationStrategy { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ToolChatMessage.Serialization.cs b/src/Generated/Models/ToolChatMessage.Serialization.cs index fb492169..315b4b5b 100644 --- a/src/Generated/Models/ToolChatMessage.Serialization.cs +++ b/src/Generated/Models/ToolChatMessage.Serialization.cs @@ -8,102 +8,101 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ToolChatMessage : IJsonModel { - public partial class ToolChatMessage : IJsonModel + ToolChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ToolChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ToolChatMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolChatMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(ToolChatMessage)} does not support reading '{format}' format."); } - internal static ToolChatMessage DeserializeToolChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolChatMessage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static ToolChatMessage DeserializeToolChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string toolCallId = default; + ChatMessageRole role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_call_id"u8)) { - return null; + toolCallId = property.Value.GetString(); + continue; } - string toolCallId = default; - ChatMessageRole role = default; - IList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("role"u8)) { - if (property.NameEquals("tool_call_id"u8)) - { - toolCallId = property.Value.GetString(); - continue; - } - if (property.NameEquals("role"u8)) - { - role = property.Value.GetString().ToChatMessageRole(); - continue; - } - if (property.NameEquals("content"u8)) - { - DeserializeContentValue(property, ref content); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + role = property.Value.GetString().ToChatMessageRole(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ToolChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, toolCallId); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("content"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ToolChatMessage)} does not support writing '{options.Format}' format."); + DeserializeContentValue(property, ref content); + continue; } - } - - ToolChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeToolChatMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolChatMessage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ToolChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, toolCallId); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new ToolChatMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeToolChatMessage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolChatMessage)} does not support writing '{options.Format}' format."); } + } + + ToolChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeToolChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolChatMessage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new ToolChatMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeToolChatMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ToolChatMessage.cs b/src/Generated/Models/ToolChatMessage.cs index d0d4c210..9f988b40 100644 --- a/src/Generated/Models/ToolChatMessage.cs +++ b/src/Generated/Models/ToolChatMessage.cs @@ -5,19 +5,18 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class ToolChatMessage : ChatMessage { - public partial class ToolChatMessage : ChatMessage + internal ToolChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string toolCallId) : base(role, content, serializedAdditionalRawData) { - internal ToolChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string toolCallId) : base(role, content, serializedAdditionalRawData) - { - ToolCallId = toolCallId; - } - - internal ToolChatMessage() - { - } + ToolCallId = toolCallId; + } - public string ToolCallId { get; } + internal ToolChatMessage() + { } -} + + public string ToolCallId { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/ToolConstraint.Serialization.cs b/src/Generated/Models/ToolConstraint.Serialization.cs index 2282c137..ab1dcdc8 100644 --- a/src/Generated/Models/ToolConstraint.Serialization.cs +++ b/src/Generated/Models/ToolConstraint.Serialization.cs @@ -7,21 +7,20 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ToolConstraint : IJsonModel { - public partial class ToolConstraint : IJsonModel - { - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - internal static ToolConstraint FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeToolConstraint(document.RootElement); - } + internal static ToolConstraint FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeToolConstraint(document.RootElement); + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ToolConstraint.cs b/src/Generated/Models/ToolConstraint.cs index 519953a5..14db915e 100644 --- a/src/Generated/Models/ToolConstraint.cs +++ b/src/Generated/Models/ToolConstraint.cs @@ -5,19 +5,18 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ToolConstraint { - public partial class ToolConstraint + internal ToolConstraint(string objectType, InternalAssistantsNamedToolChoiceFunction function, IDictionary serializedAdditionalRawData) { - internal ToolConstraint(string objectType, InternalAssistantsNamedToolChoiceFunction function, IDictionary serializedAdditionalRawData) - { - _objectType = objectType; - Function = function; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + _objectType = objectType; + Function = function; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal ToolConstraint() - { - } + internal ToolConstraint() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ToolDefinition.Serialization.cs b/src/Generated/Models/ToolDefinition.Serialization.cs index 443582ba..ba992cad 100644 --- a/src/Generated/Models/ToolDefinition.Serialization.cs +++ b/src/Generated/Models/ToolDefinition.Serialization.cs @@ -7,83 +7,82 @@ using System.ClientModel.Primitives; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +[PersistableModelProxy(typeof(UnknownAssistantToolDefinition))] +public partial class ToolDefinition : IJsonModel { - [PersistableModelProxy(typeof(UnknownAssistantToolDefinition))] - public partial class ToolDefinition : IJsonModel + ToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolDefinition(document.RootElement, options); + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{format}' format."); } - internal static ToolDefinition DeserializeToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolDefinition(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "code_interpreter": return CodeInterpreterToolDefinition.DeserializeCodeInterpreterToolDefinition(element, options); - case "file_search": return FileSearchToolDefinition.DeserializeFileSearchToolDefinition(element, options); - case "function": return FunctionToolDefinition.DeserializeFunctionToolDefinition(element, options); - } - } - return UnknownAssistantToolDefinition.DeserializeUnknownAssistantToolDefinition(element, options); - } + internal static ToolDefinition DeserializeToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); - } + return null; } - - ToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + if (element.TryGetProperty("type", out JsonElement discriminator)) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + switch (discriminator.GetString()) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{options.Format}' format."); + case "code_interpreter": return CodeInterpreterToolDefinition.DeserializeCodeInterpreterToolDefinition(element, options); + case "file_search": return FileSearchToolDefinition.DeserializeFileSearchToolDefinition(element, options); + case "function": return FunctionToolDefinition.DeserializeFunctionToolDefinition(element, options); } } + return UnknownAssistantToolDefinition.DeserializeUnknownAssistantToolDefinition(element, options); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ToolDefinition FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeToolDefinition(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); } + } + + ToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ToolDefinition FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeToolDefinition(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/ToolDefinition.cs b/src/Generated/Models/ToolDefinition.cs index 8f3a9976..be416184 100644 --- a/src/Generated/Models/ToolDefinition.cs +++ b/src/Generated/Models/ToolDefinition.cs @@ -5,21 +5,20 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public abstract partial class ToolDefinition { - public abstract partial class ToolDefinition + internal IDictionary SerializedAdditionalRawData { get; set; } + protected ToolDefinition() { - internal IDictionary SerializedAdditionalRawData { get; set; } - protected ToolDefinition() - { - } - - internal ToolDefinition(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - internal string Type { get; set; } + internal ToolDefinition(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal string Type { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ToolOutput.Serialization.cs b/src/Generated/Models/ToolOutput.Serialization.cs index d4b3f7f1..8f658ffd 100644 --- a/src/Generated/Models/ToolOutput.Serialization.cs +++ b/src/Generated/Models/ToolOutput.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ToolOutput : IJsonModel { - public partial class ToolOutput : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ToolOutput)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ToolOutput)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("tool_call_id") != true && Optional.IsDefined(ToolCallId)) - { - writer.WritePropertyName("tool_call_id"u8); - writer.WriteStringValue(ToolCallId); - } - if (SerializedAdditionalRawData?.ContainsKey("output") != true && Optional.IsDefined(Output)) - { - writer.WritePropertyName("output"u8); - writer.WriteStringValue(Output); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("tool_call_id") != true && Optional.IsDefined(ToolCallId)) + { + writer.WritePropertyName("tool_call_id"u8); + writer.WriteStringValue(ToolCallId); + } + if (SerializedAdditionalRawData?.ContainsKey("output") != true && Optional.IsDefined(Output)) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ToolOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ToolOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ToolOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolOutput(document.RootElement, options); + throw new FormatException($"The model {nameof(ToolOutput)} does not support reading '{format}' format."); } - internal static ToolOutput DeserializeToolOutput(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolOutput(document.RootElement, options); + } + + internal static ToolOutput DeserializeToolOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string toolCallId = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_call_id"u8)) { - return null; + toolCallId = property.Value.GetString(); + continue; } - string toolCallId = default; - string output = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("output"u8)) { - if (property.NameEquals("tool_call_id"u8)) - { - toolCallId = property.Value.GetString(); - continue; - } - if (property.NameEquals("output"u8)) - { - output = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + output = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ToolOutput(toolCallId, output, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ToolOutput)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ToolOutput(toolCallId, output, serializedAdditionalRawData); + } - ToolOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeToolOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolOutput)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolOutput)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ToolOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ToolOutput FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeToolOutput(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeToolOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolOutput)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ToolOutput FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeToolOutput(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ToolOutput.cs b/src/Generated/Models/ToolOutput.cs index 0e7b6441..ec33f8db 100644 --- a/src/Generated/Models/ToolOutput.cs +++ b/src/Generated/Models/ToolOutput.cs @@ -5,23 +5,22 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ToolOutput { - public partial class ToolOutput + internal IDictionary SerializedAdditionalRawData { get; set; } + public ToolOutput() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public ToolOutput() - { - } - - internal ToolOutput(string toolCallId, string output, IDictionary serializedAdditionalRawData) - { - ToolCallId = toolCallId; - Output = output; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + } - public string ToolCallId { get; set; } - public string Output { get; set; } + internal ToolOutput(string toolCallId, string output, IDictionary serializedAdditionalRawData) + { + ToolCallId = toolCallId; + Output = output; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string ToolCallId { get; set; } + public string Output { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/ToolResources.Serialization.cs b/src/Generated/Models/ToolResources.Serialization.cs index 75ceb921..5af9bbf5 100644 --- a/src/Generated/Models/ToolResources.Serialization.cs +++ b/src/Generated/Models/ToolResources.Serialization.cs @@ -8,145 +8,144 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ToolResources : IJsonModel { - public partial class ToolResources : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) - { - writer.WritePropertyName("code_interpreter"u8); - writer.WriteObjectValue(CodeInterpreter, options); - } - if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) - { - writer.WritePropertyName("file_search"u8); - SerializeFileSearch(writer, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code_interpreter") != true && Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (SerializedAdditionalRawData?.ContainsKey("file_search") != true && Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + SerializeFileSearch(writer, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - ToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolResources(document.RootElement, options); + throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{format}' format."); } - internal static ToolResources DeserializeToolResources(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolResources(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - CodeInterpreterToolResources codeInterpreter = default; - FileSearchToolResources fileSearch = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static ToolResources DeserializeToolResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterToolResources codeInterpreter = default; + FileSearchToolResources fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) { - if (property.NameEquals("code_interpreter"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - codeInterpreter = CodeInterpreterToolResources.DeserializeCodeInterpreterToolResources(property.Value, options); continue; } - if (property.NameEquals("file_search"u8)) + codeInterpreter = CodeInterpreterToolResources.DeserializeCodeInterpreterToolResources(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fileSearch = FileSearchToolResources.DeserializeFileSearchToolResources(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + fileSearch = FileSearchToolResources.DeserializeFileSearchToolResources(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new ToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new ToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); + } - ToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeToolResources(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + ToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static ToolResources FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeToolResources(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeToolResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static ToolResources FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeToolResources(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/ToolResources.cs b/src/Generated/Models/ToolResources.cs index 67b19097..df38ab6c 100644 --- a/src/Generated/Models/ToolResources.cs +++ b/src/Generated/Models/ToolResources.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class ToolResources { - public partial class ToolResources - { - internal IDictionary SerializedAdditionalRawData { get; set; } + internal IDictionary SerializedAdditionalRawData { get; set; } - internal ToolResources(CodeInterpreterToolResources codeInterpreter, FileSearchToolResources fileSearch, IDictionary serializedAdditionalRawData) - { - CodeInterpreter = codeInterpreter; - FileSearch = fileSearch; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal ToolResources(CodeInterpreterToolResources codeInterpreter, FileSearchToolResources fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} +} \ No newline at end of file diff --git a/src/Generated/Models/TranscribedSegment.Serialization.cs b/src/Generated/Models/TranscribedSegment.Serialization.cs index 71025c45..ce4ae812 100644 --- a/src/Generated/Models/TranscribedSegment.Serialization.cs +++ b/src/Generated/Models/TranscribedSegment.Serialization.cs @@ -8,252 +8,251 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial struct TranscribedSegment : IJsonModel, IJsonModel { - public partial struct TranscribedSegment : IJsonModel, IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribedSegment)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteNumberValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("seek") != true) + { + writer.WritePropertyName("seek"u8); + writer.WriteNumberValue(SeekOffset); + } + if (SerializedAdditionalRawData?.ContainsKey("start") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + writer.WritePropertyName("start"u8); + writer.WriteNumberValue(Convert.ToDouble(StartTime.ToString("s\\.FFF"))); + } + if (SerializedAdditionalRawData?.ContainsKey("end") != true) + { + writer.WritePropertyName("end"u8); + writer.WriteNumberValue(Convert.ToDouble(EndTime.ToString("s\\.FFF"))); + } + if (SerializedAdditionalRawData?.ContainsKey("text") != true) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (SerializedAdditionalRawData?.ContainsKey("tokens") != true) + { + writer.WritePropertyName("tokens"u8); + writer.WriteStartArray(); + foreach (var item in TokenIds) { - throw new FormatException($"The model {nameof(TranscribedSegment)} does not support writing '{format}' format."); + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("temperature") != true) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature); + } + if (SerializedAdditionalRawData?.ContainsKey("avg_logprob") != true) + { + writer.WritePropertyName("avg_logprob"u8); + writer.WriteNumberValue(AverageLogProbability); + } + if (SerializedAdditionalRawData?.ContainsKey("compression_ratio") != true) + { + writer.WritePropertyName("compression_ratio"u8); + writer.WriteNumberValue(CompressionRatio); + } + if (SerializedAdditionalRawData?.ContainsKey("no_speech_prob") != true) + { + writer.WritePropertyName("no_speech_prob"u8); + writer.WriteNumberValue(NoSpeechProbability); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif } + } + writer.WriteEndObject(); + } + + TranscribedSegment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TranscribedSegment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribedSegment(document.RootElement, options); + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)this).Write(writer, options); - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + object IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)this).Create(ref reader, options); + + internal static TranscribedSegment DeserializeTranscribedSegment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + int id = default; + int seek = default; + TimeSpan start = default; + TimeSpan end = default; + string text = default; + IReadOnlyList tokens = default; + float temperature = default; + float avgLogprob = default; + float compressionRatio = default; + float noSpeechProb = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - writer.WritePropertyName("id"u8); - writer.WriteNumberValue(Id); + id = property.Value.GetInt32(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("seek") != true) + if (property.NameEquals("seek"u8)) { - writer.WritePropertyName("seek"u8); - writer.WriteNumberValue(SeekOffset); + seek = property.Value.GetInt32(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("start") != true) + if (property.NameEquals("start"u8)) { - writer.WritePropertyName("start"u8); - writer.WriteNumberValue(Convert.ToDouble(StartTime.ToString("s\\.FFF"))); + start = TimeSpan.FromSeconds(property.Value.GetDouble()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("end") != true) + if (property.NameEquals("end"u8)) { - writer.WritePropertyName("end"u8); - writer.WriteNumberValue(Convert.ToDouble(EndTime.ToString("s\\.FFF"))); + end = TimeSpan.FromSeconds(property.Value.GetDouble()); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("text") != true) + if (property.NameEquals("text"u8)) { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); + text = property.Value.GetString(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("tokens") != true) + if (property.NameEquals("tokens"u8)) { - writer.WritePropertyName("tokens"u8); - writer.WriteStartArray(); - foreach (var item in TokenIds) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - writer.WriteNumberValue(item); + array.Add(item.GetInt32()); } - writer.WriteEndArray(); + tokens = array; + continue; } - if (SerializedAdditionalRawData?.ContainsKey("temperature") != true) + if (property.NameEquals("temperature"u8)) { - writer.WritePropertyName("temperature"u8); - writer.WriteNumberValue(Temperature); + temperature = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("avg_logprob") != true) + if (property.NameEquals("avg_logprob"u8)) { - writer.WritePropertyName("avg_logprob"u8); - writer.WriteNumberValue(AverageLogProbability); + avgLogprob = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("compression_ratio") != true) + if (property.NameEquals("compression_ratio"u8)) { - writer.WritePropertyName("compression_ratio"u8); - writer.WriteNumberValue(CompressionRatio); + compressionRatio = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData?.ContainsKey("no_speech_prob") != true) + if (property.NameEquals("no_speech_prob"u8)) { - writer.WritePropertyName("no_speech_prob"u8); - writer.WriteNumberValue(NoSpeechProbability); + noSpeechProb = property.Value.GetSingle(); + continue; } - if (SerializedAdditionalRawData != null) + if (true) { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } - writer.WriteEndObject(); } + serializedAdditionalRawData = rawDataDictionary; + return new TranscribedSegment( + id, + seek, + start, + end, + text, + tokens, + temperature, + avgLogprob, + compressionRatio, + noSpeechProb, + serializedAdditionalRawData); + } - TranscribedSegment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(TranscribedSegment)} does not support reading '{format}' format."); - } + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTranscribedSegment(document.RootElement, options); + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscribedSegment)} does not support writing '{options.Format}' format."); } + } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)this).Write(writer, options); - - object IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)this).Create(ref reader, options); + TranscribedSegment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static TranscribedSegment DeserializeTranscribedSegment(JsonElement element, ModelReaderWriterOptions options = null) + switch (format) { - options ??= ModelSerializationExtensions.WireOptions; - - int id = default; - int seek = default; - TimeSpan start = default; - TimeSpan end = default; - string text = default; - IReadOnlyList tokens = default; - float temperature = default; - float avgLogprob = default; - float compressionRatio = default; - float noSpeechProb = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("seek"u8)) - { - seek = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("start"u8)) - { - start = TimeSpan.FromSeconds(property.Value.GetDouble()); - continue; - } - if (property.NameEquals("end"u8)) - { - end = TimeSpan.FromSeconds(property.Value.GetDouble()); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("tokens"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetInt32()); - } - tokens = array; - continue; - } - if (property.NameEquals("temperature"u8)) - { - temperature = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("avg_logprob"u8)) - { - avgLogprob = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("compression_ratio"u8)) - { - compressionRatio = property.Value.GetSingle(); - continue; - } - if (property.NameEquals("no_speech_prob"u8)) - { - noSpeechProb = property.Value.GetSingle(); - continue; - } - if (true) + case "J": { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscribedSegment(document.RootElement, options); } - } - serializedAdditionalRawData = rawDataDictionary; - return new TranscribedSegment( - id, - seek, - start, - end, - text, - tokens, - temperature, - avgLogprob, - compressionRatio, - noSpeechProb, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(TranscribedSegment)} does not support writing '{options.Format}' format."); - } - } - - TranscribedSegment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeTranscribedSegment(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TranscribedSegment)} does not support reading '{options.Format}' format."); - } + default: + throw new FormatException($"The model {nameof(TranscribedSegment)} does not support reading '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ((IPersistableModel)this).Write(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ((IPersistableModel)this).Write(options); - object IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ((IPersistableModel)this).Create(data, options); + object IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ((IPersistableModel)this).Create(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)this).GetFormatFromOptions(options); + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)this).GetFormatFromOptions(options); - internal static TranscribedSegment FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeTranscribedSegment(document.RootElement); - } + internal static TranscribedSegment FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscribedSegment(document.RootElement); + } - internal BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + internal BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/TranscribedSegment.cs b/src/Generated/Models/TranscribedSegment.cs index 5f27659f..d2bda375 100644 --- a/src/Generated/Models/TranscribedSegment.cs +++ b/src/Generated/Models/TranscribedSegment.cs @@ -6,49 +6,48 @@ using System.Collections.Generic; using System.Linq; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public readonly partial struct TranscribedSegment { - public readonly partial struct TranscribedSegment + internal TranscribedSegment(int id, int seekOffset, TimeSpan startTime, TimeSpan endTime, string text, IEnumerable tokenIds, float temperature, float averageLogProbability, float compressionRatio, float noSpeechProbability) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(tokenIds, nameof(tokenIds)); + + Id = id; + SeekOffset = seekOffset; + StartTime = startTime; + EndTime = endTime; + Text = text; + TokenIds = tokenIds.ToList(); + Temperature = temperature; + AverageLogProbability = averageLogProbability; + CompressionRatio = compressionRatio; + NoSpeechProbability = noSpeechProbability; + } + + internal TranscribedSegment(int id, int seekOffset, TimeSpan startTime, TimeSpan endTime, string text, IReadOnlyList tokenIds, float temperature, float averageLogProbability, float compressionRatio, float noSpeechProbability, IDictionary serializedAdditionalRawData) { - internal TranscribedSegment(int id, int seekOffset, TimeSpan startTime, TimeSpan endTime, string text, IEnumerable tokenIds, float temperature, float averageLogProbability, float compressionRatio, float noSpeechProbability) - { - Argument.AssertNotNull(text, nameof(text)); - Argument.AssertNotNull(tokenIds, nameof(tokenIds)); - - Id = id; - SeekOffset = seekOffset; - StartTime = startTime; - EndTime = endTime; - Text = text; - TokenIds = tokenIds.ToList(); - Temperature = temperature; - AverageLogProbability = averageLogProbability; - CompressionRatio = compressionRatio; - NoSpeechProbability = noSpeechProbability; - } - - internal TranscribedSegment(int id, int seekOffset, TimeSpan startTime, TimeSpan endTime, string text, IReadOnlyList tokenIds, float temperature, float averageLogProbability, float compressionRatio, float noSpeechProbability, IDictionary serializedAdditionalRawData) - { - Id = id; - SeekOffset = seekOffset; - StartTime = startTime; - EndTime = endTime; - Text = text; - TokenIds = tokenIds; - Temperature = temperature; - AverageLogProbability = averageLogProbability; - CompressionRatio = compressionRatio; - NoSpeechProbability = noSpeechProbability; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - public TranscribedSegment() - { - } - - public int Id { get; } - public string Text { get; } - public float Temperature { get; } - public float CompressionRatio { get; } + Id = id; + SeekOffset = seekOffset; + StartTime = startTime; + EndTime = endTime; + Text = text; + TokenIds = tokenIds; + Temperature = temperature; + AverageLogProbability = averageLogProbability; + CompressionRatio = compressionRatio; + NoSpeechProbability = noSpeechProbability; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public TranscribedSegment() + { + } + + public int Id { get; } + public string Text { get; } + public float Temperature { get; } + public float CompressionRatio { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/TranscribedWord.Serialization.cs b/src/Generated/Models/TranscribedWord.Serialization.cs index c3e0cc0f..09f5b04f 100644 --- a/src/Generated/Models/TranscribedWord.Serialization.cs +++ b/src/Generated/Models/TranscribedWord.Serialization.cs @@ -8,154 +8,153 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public partial struct TranscribedWord : IJsonModel, IJsonModel { - public partial struct TranscribedWord : IJsonModel, IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(TranscribedWord)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(TranscribedWord)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("word") != true) - { - writer.WritePropertyName("word"u8); - writer.WriteStringValue(Word); - } - if (SerializedAdditionalRawData?.ContainsKey("start") != true) - { - writer.WritePropertyName("start"u8); - writer.WriteNumberValue(Convert.ToDouble(StartTime.ToString("s\\.FFF"))); - } - if (SerializedAdditionalRawData?.ContainsKey("end") != true) - { - writer.WritePropertyName("end"u8); - writer.WriteNumberValue(Convert.ToDouble(EndTime.ToString("s\\.FFF"))); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("word") != true) + { + writer.WritePropertyName("word"u8); + writer.WriteStringValue(Word); + } + if (SerializedAdditionalRawData?.ContainsKey("start") != true) + { + writer.WritePropertyName("start"u8); + writer.WriteNumberValue(Convert.ToDouble(StartTime.ToString("s\\.FFF"))); + } + if (SerializedAdditionalRawData?.ContainsKey("end") != true) + { + writer.WritePropertyName("end"u8); + writer.WriteNumberValue(Convert.ToDouble(EndTime.ToString("s\\.FFF"))); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - TranscribedWord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + TranscribedWord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(TranscribedWord)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTranscribedWord(document.RootElement, options); + throw new FormatException($"The model {nameof(TranscribedWord)} does not support reading '{format}' format."); } - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)this).Write(writer, options); + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTranscribedWord(document.RootElement, options); + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)this).Write(writer, options); - object IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)this).Create(ref reader, options); + object IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)this).Create(ref reader, options); - internal static TranscribedWord DeserializeTranscribedWord(JsonElement element, ModelReaderWriterOptions options = null) + internal static TranscribedWord DeserializeTranscribedWord(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + string word = default; + TimeSpan start = default; + TimeSpan end = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - options ??= ModelSerializationExtensions.WireOptions; - - string word = default; - TimeSpan start = default; - TimeSpan end = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("word"u8)) { - if (property.NameEquals("word"u8)) - { - word = property.Value.GetString(); - continue; - } - if (property.NameEquals("start"u8)) - { - start = TimeSpan.FromSeconds(property.Value.GetDouble()); - continue; - } - if (property.NameEquals("end"u8)) - { - end = TimeSpan.FromSeconds(property.Value.GetDouble()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + word = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new TranscribedWord(word, start, end, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("start"u8)) + { + start = TimeSpan.FromSeconds(property.Value.GetDouble()); + continue; + } + if (property.NameEquals("end"u8)) + { + end = TimeSpan.FromSeconds(property.Value.GetDouble()); + continue; + } + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(TranscribedWord)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new TranscribedWord(word, start, end, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - TranscribedWord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + switch (format) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TranscribedWord)} does not support writing '{options.Format}' format."); + } + } - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeTranscribedWord(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TranscribedWord)} does not support reading '{options.Format}' format."); - } + TranscribedWord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTranscribedWord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TranscribedWord)} does not support reading '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ((IPersistableModel)this).Write(options); + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ((IPersistableModel)this).Write(options); - object IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ((IPersistableModel)this).Create(data, options); + object IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ((IPersistableModel)this).Create(data, options); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)this).GetFormatFromOptions(options); + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)this).GetFormatFromOptions(options); - internal static TranscribedWord FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeTranscribedWord(document.RootElement); - } + internal static TranscribedWord FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTranscribedWord(document.RootElement); + } - internal BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + internal BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/TranscribedWord.cs b/src/Generated/Models/TranscribedWord.cs index 1ccbc4f8..40491938 100644 --- a/src/Generated/Models/TranscribedWord.cs +++ b/src/Generated/Models/TranscribedWord.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.Audio +namespace OpenAI.Audio; + +public readonly partial struct TranscribedWord { - public readonly partial struct TranscribedWord + internal TranscribedWord(string word, TimeSpan startTime, TimeSpan endTime) + { + Argument.AssertNotNull(word, nameof(word)); + + Word = word; + StartTime = startTime; + EndTime = endTime; + } + + internal TranscribedWord(string word, TimeSpan startTime, TimeSpan endTime, IDictionary serializedAdditionalRawData) { - internal TranscribedWord(string word, TimeSpan startTime, TimeSpan endTime) - { - Argument.AssertNotNull(word, nameof(word)); - - Word = word; - StartTime = startTime; - EndTime = endTime; - } - - internal TranscribedWord(string word, TimeSpan startTime, TimeSpan endTime, IDictionary serializedAdditionalRawData) - { - Word = word; - StartTime = startTime; - EndTime = endTime; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - public TranscribedWord() - { - } - - public string Word { get; } + Word = word; + StartTime = startTime; + EndTime = endTime; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public TranscribedWord() + { + } + + public string Word { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownAssistantToolDefinition.Serialization.cs b/src/Generated/Models/UnknownAssistantToolDefinition.Serialization.cs index b26d26d0..8e83ba26 100644 --- a/src/Generated/Models/UnknownAssistantToolDefinition.Serialization.cs +++ b/src/Generated/Models/UnknownAssistantToolDefinition.Serialization.cs @@ -8,90 +8,89 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownAssistantToolDefinition : IJsonModel { - internal partial class UnknownAssistantToolDefinition : IJsonModel + ToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - ToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeToolDefinition(document.RootElement, options); + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{format}' format."); } - internal static UnknownAssistantToolDefinition DeserializeUnknownAssistantToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolDefinition(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownAssistantToolDefinition(type, serializedAdditionalRawData); - } + internal static UnknownAssistantToolDefinition DeserializeUnknownAssistantToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + if (element.ValueKind == JsonValueKind.Null) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); - } + return null; } - - ToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownAssistantToolDefinition(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownAssistantToolDefinition FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownAssistantToolDefinition(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support writing '{options.Format}' format."); } + } + + ToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolDefinition)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownAssistantToolDefinition FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownAssistantToolDefinition(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownAssistantToolDefinition.cs b/src/Generated/Models/UnknownAssistantToolDefinition.cs index ca5c335e..47e46412 100644 --- a/src/Generated/Models/UnknownAssistantToolDefinition.cs +++ b/src/Generated/Models/UnknownAssistantToolDefinition.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownAssistantToolDefinition : ToolDefinition { - internal partial class UnknownAssistantToolDefinition : ToolDefinition + internal UnknownAssistantToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownAssistantToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownAssistantToolDefinition() - { - } + internal UnknownAssistantToolDefinition() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.Serialization.cs b/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.Serialization.cs index 7e77542b..5932d803 100644 --- a/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.Serialization.cs +++ b/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class UnknownCreateFineTuningJobRequestIntegration : IJsonModel { - internal partial class UnknownCreateFineTuningJobRequestIntegration : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{format}' format."); } - FineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeFineTuningIntegration(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownCreateFineTuningJobRequestIntegration DeserializeUnknownCreateFineTuningJobRequestIntegration(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownCreateFineTuningJobRequestIntegration(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + FineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{format}' format."); } - FineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFineTuningIntegration(document.RootElement, options); + } + + internal static UnknownCreateFineTuningJobRequestIntegration DeserializeUnknownCreateFineTuningJobRequestIntegration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeFineTuningIntegration(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownCreateFineTuningJobRequestIntegration(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownCreateFineTuningJobRequestIntegration FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownCreateFineTuningJobRequestIntegration(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support writing '{options.Format}' format."); } + } + + FineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFineTuningIntegration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FineTuningIntegration)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownCreateFineTuningJobRequestIntegration FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownCreateFineTuningJobRequestIntegration(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.cs b/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.cs index cbf12dee..51899647 100644 --- a/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.cs +++ b/src/Generated/Models/UnknownCreateFineTuningJobRequestIntegration.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class UnknownCreateFineTuningJobRequestIntegration : FineTuningIntegration { - internal partial class UnknownCreateFineTuningJobRequestIntegration : FineTuningIntegration + internal UnknownCreateFineTuningJobRequestIntegration(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownCreateFineTuningJobRequestIntegration(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownCreateFineTuningJobRequestIntegration() - { - } + internal UnknownCreateFineTuningJobRequestIntegration() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownFineTuningIntegration.Serialization.cs b/src/Generated/Models/UnknownFineTuningIntegration.Serialization.cs index dd39b6cd..e766c9b7 100644 --- a/src/Generated/Models/UnknownFineTuningIntegration.Serialization.cs +++ b/src/Generated/Models/UnknownFineTuningIntegration.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class UnknownFineTuningIntegration : IJsonModel { - internal partial class UnknownFineTuningIntegration : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{format}' format."); } - InternalFineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalFineTuningIntegration(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownFineTuningIntegration DeserializeUnknownFineTuningIntegration(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownFineTuningIntegration(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalFineTuningIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{format}' format."); } - InternalFineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFineTuningIntegration(document.RootElement, options); + } + + internal static UnknownFineTuningIntegration DeserializeUnknownFineTuningIntegration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalFineTuningIntegration(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownFineTuningIntegration(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownFineTuningIntegration FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownFineTuningIntegration(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support writing '{options.Format}' format."); } + } + + InternalFineTuningIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalFineTuningIntegration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFineTuningIntegration)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownFineTuningIntegration FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownFineTuningIntegration(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownFineTuningIntegration.cs b/src/Generated/Models/UnknownFineTuningIntegration.cs index 8252f257..185fcd8e 100644 --- a/src/Generated/Models/UnknownFineTuningIntegration.cs +++ b/src/Generated/Models/UnknownFineTuningIntegration.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class UnknownFineTuningIntegration : InternalFineTuningIntegration { - internal partial class UnknownFineTuningIntegration : InternalFineTuningIntegration + internal UnknownFineTuningIntegration(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownFineTuningIntegration(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownFineTuningIntegration() - { - } + internal UnknownFineTuningIntegration() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.Serialization.cs b/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.Serialization.cs index b0a6d958..aaea83fa 100644 --- a/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.Serialization.cs +++ b/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownMessageContentTextObjectAnnotation : IJsonModel { - internal partial class UnknownMessageContentTextObjectAnnotation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{format}' format."); } - InternalMessageContentTextObjectAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownMessageContentTextObjectAnnotation DeserializeUnknownMessageContentTextObjectAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownMessageContentTextObjectAnnotation(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalMessageContentTextObjectAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{format}' format."); } - InternalMessageContentTextObjectAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); + } + + internal static UnknownMessageContentTextObjectAnnotation DeserializeUnknownMessageContentTextObjectAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageContentTextObjectAnnotation(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownMessageContentTextObjectAnnotation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownMessageContentTextObjectAnnotation(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support writing '{options.Format}' format."); } + } + + InternalMessageContentTextObjectAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageContentTextObjectAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageContentTextObjectAnnotation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownMessageContentTextObjectAnnotation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownMessageContentTextObjectAnnotation(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.cs b/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.cs index b5561f7c..b0327e96 100644 --- a/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.cs +++ b/src/Generated/Models/UnknownMessageContentTextObjectAnnotation.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownMessageContentTextObjectAnnotation : InternalMessageContentTextObjectAnnotation { - internal partial class UnknownMessageContentTextObjectAnnotation : InternalMessageContentTextObjectAnnotation + internal UnknownMessageContentTextObjectAnnotation(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownMessageContentTextObjectAnnotation(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownMessageContentTextObjectAnnotation() - { - } + internal UnknownMessageContentTextObjectAnnotation() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownMessageDeltaContent.Serialization.cs b/src/Generated/Models/UnknownMessageDeltaContent.Serialization.cs index f4570019..1ddfb0b8 100644 --- a/src/Generated/Models/UnknownMessageDeltaContent.Serialization.cs +++ b/src/Generated/Models/UnknownMessageDeltaContent.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownMessageDeltaContent : IJsonModel { - internal partial class UnknownMessageDeltaContent : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{format}' format."); } - InternalMessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContent(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownMessageDeltaContent DeserializeUnknownMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownMessageDeltaContent(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalMessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{format}' format."); } - InternalMessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaContent(document.RootElement, options); + } + + internal static UnknownMessageDeltaContent DeserializeUnknownMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageDeltaContent(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownMessageDeltaContent FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownMessageDeltaContent(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaContent)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownMessageDeltaContent FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownMessageDeltaContent(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownMessageDeltaContent.cs b/src/Generated/Models/UnknownMessageDeltaContent.cs index a33b7445..9553405c 100644 --- a/src/Generated/Models/UnknownMessageDeltaContent.cs +++ b/src/Generated/Models/UnknownMessageDeltaContent.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownMessageDeltaContent : InternalMessageDeltaContent { - internal partial class UnknownMessageDeltaContent : InternalMessageDeltaContent + internal UnknownMessageDeltaContent(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownMessageDeltaContent(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownMessageDeltaContent() - { - } + internal UnknownMessageDeltaContent() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.Serialization.cs b/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.Serialization.cs index 1fda24c5..5a0794e0 100644 --- a/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.Serialization.cs +++ b/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownMessageDeltaTextContentAnnotation : IJsonModel { - internal partial class UnknownMessageDeltaTextContentAnnotation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{format}' format."); } - InternalMessageDeltaTextContentAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownMessageDeltaTextContentAnnotation DeserializeUnknownMessageDeltaTextContentAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownMessageDeltaTextContentAnnotation(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalMessageDeltaTextContentAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{format}' format."); } - InternalMessageDeltaTextContentAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); + } + + internal static UnknownMessageDeltaTextContentAnnotation DeserializeUnknownMessageDeltaTextContentAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageDeltaTextContentAnnotation(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownMessageDeltaTextContentAnnotation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownMessageDeltaTextContentAnnotation(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support writing '{options.Format}' format."); } + } + + InternalMessageDeltaTextContentAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalMessageDeltaTextContentAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMessageDeltaTextContentAnnotation)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownMessageDeltaTextContentAnnotation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownMessageDeltaTextContentAnnotation(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.cs b/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.cs index d6f17c1a..73d8f4de 100644 --- a/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.cs +++ b/src/Generated/Models/UnknownMessageDeltaTextContentAnnotation.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownMessageDeltaTextContentAnnotation : InternalMessageDeltaTextContentAnnotation { - internal partial class UnknownMessageDeltaTextContentAnnotation : InternalMessageDeltaTextContentAnnotation + internal UnknownMessageDeltaTextContentAnnotation(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownMessageDeltaTextContentAnnotation(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownMessageDeltaTextContentAnnotation() - { - } + internal UnknownMessageDeltaTextContentAnnotation() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDeltaStepDetails.Serialization.cs b/src/Generated/Models/UnknownRunStepDeltaStepDetails.Serialization.cs index 287960a6..92750bf2 100644 --- a/src/Generated/Models/UnknownRunStepDeltaStepDetails.Serialization.cs +++ b/src/Generated/Models/UnknownRunStepDeltaStepDetails.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDeltaStepDetails : IJsonModel { - internal partial class UnknownRunStepDeltaStepDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{format}' format."); } - InternalRunStepDeltaStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownRunStepDeltaStepDetails DeserializeUnknownRunStepDeltaStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepDeltaStepDetails(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{format}' format."); } - InternalRunStepDeltaStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); + } + + internal static UnknownRunStepDeltaStepDetails DeserializeUnknownRunStepDeltaStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaStepDetails(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownRunStepDeltaStepDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownRunStepDeltaStepDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownRunStepDeltaStepDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepDeltaStepDetails(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDeltaStepDetails.cs b/src/Generated/Models/UnknownRunStepDeltaStepDetails.cs index d5609148..8c1d2849 100644 --- a/src/Generated/Models/UnknownRunStepDeltaStepDetails.cs +++ b/src/Generated/Models/UnknownRunStepDeltaStepDetails.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDeltaStepDetails : InternalRunStepDeltaStepDetails { - internal partial class UnknownRunStepDeltaStepDetails : InternalRunStepDeltaStepDetails + internal UnknownRunStepDeltaStepDetails(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownRunStepDeltaStepDetails(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownRunStepDeltaStepDetails() - { - } + internal UnknownRunStepDeltaStepDetails() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs index 4790ac0f..780198e7 100644 --- a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs +++ b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : IJsonModel { - internal partial class UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{format}' format."); } - RunStepUpdateCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject DeserializeUnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + RunStepUpdateCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{format}' format."); } - RunStepUpdateCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); + } + + internal static UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject DeserializeUnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support writing '{options.Format}' format."); } + } + + RunStepUpdateCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepUpdateCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepUpdateCodeInterpreterOutput)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs index d57ff039..dfa708bf 100644 --- a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs +++ b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : RunStepUpdateCodeInterpreterOutput { - internal partial class UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : RunStepUpdateCodeInterpreterOutput + internal UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject() - { - } + internal UnknownRunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs index b5bcbda2..d79da148 100644 --- a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs +++ b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject : IJsonModel { - internal partial class UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{format}' format."); } - InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject DeserializeUnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{format}' format."); } - InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); + } + + internal static UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject DeserializeUnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support writing '{options.Format}' format."); } + } + + InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs index 5a0c3e67..35668412 100644 --- a/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs +++ b/src/Generated/Models/UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject { - internal partial class UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject : InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject + internal UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject() - { - } + internal UnknownRunStepDeltaStepDetailsToolCallsObjectToolCallsObject() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs b/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs index 86648d23..5123ba76 100644 --- a/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs +++ b/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : IJsonModel { - internal partial class UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{format}' format."); } - RunStepCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject DeserializeUnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + RunStepCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{format}' format."); } - RunStepCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); + } + + internal static UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject DeserializeUnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support writing '{options.Format}' format."); } + } + + RunStepCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCodeInterpreterOutput)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs b/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs index 210c6b0a..da766735 100644 --- a/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs +++ b/src/Generated/Models/UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : RunStepCodeInterpreterOutput { - internal partial class UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject : RunStepCodeInterpreterOutput + internal UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject() - { - } + internal UnknownRunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.Serialization.cs b/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.Serialization.cs index 79e5d73d..c07879ba 100644 --- a/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.Serialization.cs +++ b/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDetailsToolCallsObjectToolCallsObject : IJsonModel { - internal partial class UnknownRunStepDetailsToolCallsObjectToolCallsObject : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{format}' format."); } - RunStepToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepToolCall(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownRunStepDetailsToolCallsObjectToolCallsObject DeserializeUnknownRunStepDetailsToolCallsObjectToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepDetailsToolCallsObjectToolCallsObject(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + RunStepToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{format}' format."); } - RunStepToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepToolCall(document.RootElement, options); + } + + internal static UnknownRunStepDetailsToolCallsObjectToolCallsObject DeserializeUnknownRunStepDetailsToolCallsObjectToolCallsObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepToolCall(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDetailsToolCallsObjectToolCallsObject(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownRunStepDetailsToolCallsObjectToolCallsObject FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownRunStepDetailsToolCallsObjectToolCallsObject(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support writing '{options.Format}' format."); } + } + + RunStepToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepToolCall)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownRunStepDetailsToolCallsObjectToolCallsObject FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepDetailsToolCallsObjectToolCallsObject(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.cs b/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.cs index fa779e44..acb550c6 100644 --- a/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.cs +++ b/src/Generated/Models/UnknownRunStepDetailsToolCallsObjectToolCallsObject.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepDetailsToolCallsObjectToolCallsObject : RunStepToolCall { - internal partial class UnknownRunStepDetailsToolCallsObjectToolCallsObject : RunStepToolCall + internal UnknownRunStepDetailsToolCallsObjectToolCallsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownRunStepDetailsToolCallsObjectToolCallsObject(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownRunStepDetailsToolCallsObjectToolCallsObject() - { - } + internal UnknownRunStepDetailsToolCallsObjectToolCallsObject() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepObjectStepDetails.Serialization.cs b/src/Generated/Models/UnknownRunStepObjectStepDetails.Serialization.cs index 142bdc28..847eea90 100644 --- a/src/Generated/Models/UnknownRunStepObjectStepDetails.Serialization.cs +++ b/src/Generated/Models/UnknownRunStepObjectStepDetails.Serialization.cs @@ -8,126 +8,125 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepObjectStepDetails : IJsonModel { - internal partial class UnknownRunStepObjectStepDetails : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{format}' format."); } - RunStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("type") != true) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepDetails(document.RootElement, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); } - - internal static UnknownRunStepObjectStepDetails DeserializeUnknownRunStepObjectStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + if (SerializedAdditionalRawData != null) { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var item in SerializedAdditionalRawData) { - if (property.NameEquals("type"u8)) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - type = property.Value.GetString(); continue; } - if (true) + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - serializedAdditionalRawData = rawDataDictionary; - return new UnknownRunStepObjectStepDetails(type, serializedAdditionalRawData); } + writer.WriteEndObject(); + } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + RunStepDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); - } + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{format}' format."); } - RunStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDetails(document.RootElement, options); + } + + internal static UnknownRunStepObjectStepDetails DeserializeUnknownRunStepObjectStepDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - switch (format) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepDetails(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{options.Format}' format."); + type = property.Value.GetString(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepObjectStepDetails(type, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UnknownRunStepObjectStepDetails FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUnknownRunStepObjectStepDetails(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support writing '{options.Format}' format."); } + } + + RunStepDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDetails)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UnknownRunStepObjectStepDetails FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepObjectStepDetails(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UnknownRunStepObjectStepDetails.cs b/src/Generated/Models/UnknownRunStepObjectStepDetails.cs index e91259e4..63c41703 100644 --- a/src/Generated/Models/UnknownRunStepObjectStepDetails.cs +++ b/src/Generated/Models/UnknownRunStepObjectStepDetails.cs @@ -5,16 +5,15 @@ using System; using System.Collections.Generic; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +internal partial class UnknownRunStepObjectStepDetails : RunStepDetails { - internal partial class UnknownRunStepObjectStepDetails : RunStepDetails + internal UnknownRunStepObjectStepDetails(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) { - internal UnknownRunStepObjectStepDetails(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } + } - internal UnknownRunStepObjectStepDetails() - { - } + internal UnknownRunStepObjectStepDetails() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/UserChatMessage.Serialization.cs b/src/Generated/Models/UserChatMessage.Serialization.cs index c6fdb45b..4d7321de 100644 --- a/src/Generated/Models/UserChatMessage.Serialization.cs +++ b/src/Generated/Models/UserChatMessage.Serialization.cs @@ -8,102 +8,101 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class UserChatMessage : IJsonModel { - public partial class UserChatMessage : IJsonModel + UserChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - UserChatMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(UserChatMessage)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUserChatMessage(document.RootElement, options); + throw new FormatException($"The model {nameof(UserChatMessage)} does not support reading '{format}' format."); } - internal static UserChatMessage DeserializeUserChatMessage(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserChatMessage(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static UserChatMessage DeserializeUserChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + ChatMessageRole role = default; + IList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - return null; + name = property.Value.GetString(); + continue; } - string name = default; - ChatMessageRole role = default; - IList content = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("role"u8)) { - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("role"u8)) - { - role = property.Value.GetString().ToChatMessageRole(); - continue; - } - if (property.NameEquals("content"u8)) - { - DeserializeContentValue(property, ref content); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + role = property.Value.GetString().ToChatMessageRole(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new UserChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, name); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("content"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(UserChatMessage)} does not support writing '{options.Format}' format."); + DeserializeContentValue(property, ref content); + continue; } - } - - UserChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeUserChatMessage(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(UserChatMessage)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new UserChatMessage(role, content ?? new ChangeTrackingList(), serializedAdditionalRawData, name); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new UserChatMessage FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUserChatMessage(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UserChatMessage)} does not support writing '{options.Format}' format."); } + } + + UserChatMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal override BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUserChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserChatMessage)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new UserChatMessage FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUserChatMessage(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/UserChatMessage.cs b/src/Generated/Models/UserChatMessage.cs index 65a986eb..d0eec15f 100644 --- a/src/Generated/Models/UserChatMessage.cs +++ b/src/Generated/Models/UserChatMessage.cs @@ -5,17 +5,16 @@ using System; using System.Collections.Generic; -namespace OpenAI.Chat +namespace OpenAI.Chat; + +public partial class UserChatMessage : ChatMessage { - public partial class UserChatMessage : ChatMessage + internal UserChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string participantName) : base(role, content, serializedAdditionalRawData) { - internal UserChatMessage(ChatMessageRole role, IList content, IDictionary serializedAdditionalRawData, string participantName) : base(role, content, serializedAdditionalRawData) - { - ParticipantName = participantName; - } + ParticipantName = participantName; + } - internal UserChatMessage() - { - } + internal UserChatMessage() + { } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStore.Serialization.cs b/src/Generated/Models/VectorStore.Serialization.cs index d2aacb78..6937003c 100644 --- a/src/Generated/Models/VectorStore.Serialization.cs +++ b/src/Generated/Models/VectorStore.Serialization.cs @@ -8,299 +8,298 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStore : IJsonModel { - public partial class VectorStore : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) - { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("name") != true) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (SerializedAdditionalRawData?.ContainsKey("usage_bytes") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("usage_bytes") != true) + { + writer.WritePropertyName("usage_bytes"u8); + writer.WriteNumberValue(UsageBytes); + } + if (SerializedAdditionalRawData?.ContainsKey("file_counts") != true) + { + writer.WritePropertyName("file_counts"u8); + writer.WriteObjectValue(FileCounts, options); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("expires_after") != true && Optional.IsDefined(ExpirationPolicy)) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpirationPolicy, options); + } + if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true && Optional.IsDefined(ExpiresAt)) + { + if (ExpiresAt != null) { - writer.WritePropertyName("usage_bytes"u8); - writer.WriteNumberValue(UsageBytes); + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("file_counts") != true) + else { - writer.WritePropertyName("file_counts"u8); - writer.WriteObjectValue(FileCounts, options); + writer.WriteNull("expires_at"); } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("last_active_at") != true) + { + if (LastActiveAt != null) { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToSerialString()); + writer.WritePropertyName("last_active_at"u8); + writer.WriteNumberValue(LastActiveAt.Value, "U"); } - if (SerializedAdditionalRawData?.ContainsKey("expires_after") != true && Optional.IsDefined(ExpirationPolicy)) + else { - writer.WritePropertyName("expires_after"u8); - writer.WriteObjectValue(ExpirationPolicy, options); + writer.WriteNull("last_active_at"); } - if (SerializedAdditionalRawData?.ContainsKey("expires_at") != true && Optional.IsDefined(ExpiresAt)) + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + { + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { - if (ExpiresAt != null) - { - writer.WritePropertyName("expires_at"u8); - writer.WriteNumberValue(ExpiresAt.Value, "U"); - } - else + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("expires_at"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("last_active_at") != true) + else { - if (LastActiveAt != null) - { - writer.WritePropertyName("last_active_at"u8); - writer.WriteNumberValue(LastActiveAt.Value, "U"); - } - else - { - writer.WriteNull("last_active_at"); - } + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Metadata != null && Optional.IsCollectionDefined(Metadata)) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("metadata"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStore(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{format}' format."); } - internal static VectorStore DeserializeVectorStore(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStore(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static VectorStore DeserializeVectorStore(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalVectorStoreObjectObject @object = default; + DateTimeOffset createdAt = default; + string name = default; + int usageBytes = default; + VectorStoreFileCounts fileCounts = default; + VectorStoreStatus status = default; + VectorStoreExpirationPolicy expiresAfter = default; + DateTimeOffset? expiresAt = default; + DateTimeOffset? lastActiveAt = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalVectorStoreObjectObject @object = default; - DateTimeOffset createdAt = default; - string name = default; - int usageBytes = default; - VectorStoreFileCounts fileCounts = default; - VectorStoreStatus status = default; - VectorStoreExpirationPolicy expiresAfter = default; - DateTimeOffset? expiresAt = default; - DateTimeOffset? lastActiveAt = default; - IReadOnlyDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalVectorStoreObjectObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("usage_bytes"u8)) - { - usageBytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("file_counts"u8)) - { - fileCounts = VectorStoreFileCounts.DeserializeVectorStoreFileCounts(property.Value, options); - continue; - } - if (property.NameEquals("status"u8)) - { - status = property.Value.GetString().ToVectorStoreStatus(); - continue; - } - if (property.NameEquals("expires_after"u8)) + @object = new InternalVectorStoreObjectObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("usage_bytes"u8)) + { + usageBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("file_counts"u8)) + { + fileCounts = VectorStoreFileCounts.DeserializeVectorStoreFileCounts(property.Value, options); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString().ToVectorStoreStatus(); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); continue; } - if (property.NameEquals("expires_at"u8)) + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("expires_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - expiresAt = null; - continue; - } - expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + expiresAt = null; continue; } - if (property.NameEquals("last_active_at"u8)) + expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("last_active_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastActiveAt = null; - continue; - } - lastActiveAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + lastActiveAt = null; continue; } - if (property.NameEquals("metadata"u8)) + lastActiveAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - metadata = new ChangeTrackingDictionary(); - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; + metadata = new ChangeTrackingDictionary(); continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStore( - id, - @object, - createdAt, - name, - usageBytes, - fileCounts, - status, - expiresAfter, - expiresAt, - lastActiveAt, - metadata, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStore( + id, + @object, + createdAt, + name, + usageBytes, + fileCounts, + status, + expiresAfter, + expiresAt, + lastActiveAt, + metadata, + serializedAdditionalRawData); + } - VectorStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStore(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + VectorStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStore FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStore(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStore FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStore(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStore.cs b/src/Generated/Models/VectorStore.cs index 3f39a41e..598761d5 100644 --- a/src/Generated/Models/VectorStore.cs +++ b/src/Generated/Models/VectorStore.cs @@ -5,56 +5,55 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStore { - public partial class VectorStore + internal IDictionary SerializedAdditionalRawData { get; set; } + internal VectorStore(string id, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCounts fileCounts, VectorStoreStatus status, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(fileCounts, nameof(fileCounts)); + + Id = id; + CreatedAt = createdAt; + Name = name; + UsageBytes = usageBytes; + FileCounts = fileCounts; + Status = status; + LastActiveAt = lastActiveAt; + Metadata = metadata; + } + + internal VectorStore(string id, InternalVectorStoreObjectObject @object, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCounts fileCounts, VectorStoreStatus status, VectorStoreExpirationPolicy expirationPolicy, DateTimeOffset? expiresAt, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal VectorStore(string id, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCounts fileCounts, VectorStoreStatus status, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(name, nameof(name)); - Argument.AssertNotNull(fileCounts, nameof(fileCounts)); - - Id = id; - CreatedAt = createdAt; - Name = name; - UsageBytes = usageBytes; - FileCounts = fileCounts; - Status = status; - LastActiveAt = lastActiveAt; - Metadata = metadata; - } - - internal VectorStore(string id, InternalVectorStoreObjectObject @object, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCounts fileCounts, VectorStoreStatus status, VectorStoreExpirationPolicy expirationPolicy, DateTimeOffset? expiresAt, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) - { - Id = id; - Object = @object; - CreatedAt = createdAt; - Name = name; - UsageBytes = usageBytes; - FileCounts = fileCounts; - Status = status; - ExpirationPolicy = expirationPolicy; - ExpiresAt = expiresAt; - LastActiveAt = lastActiveAt; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal VectorStore() - { - } - - public string Id { get; } - - public DateTimeOffset CreatedAt { get; } - public string Name { get; } - public int UsageBytes { get; } - public VectorStoreFileCounts FileCounts { get; } - public VectorStoreStatus Status { get; } - public DateTimeOffset? ExpiresAt { get; } - public DateTimeOffset? LastActiveAt { get; } - public IReadOnlyDictionary Metadata { get; } + Id = id; + Object = @object; + CreatedAt = createdAt; + Name = name; + UsageBytes = usageBytes; + FileCounts = fileCounts; + Status = status; + ExpirationPolicy = expirationPolicy; + ExpiresAt = expiresAt; + LastActiveAt = lastActiveAt; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal VectorStore() + { + } + + public string Id { get; } + + public DateTimeOffset CreatedAt { get; } + public string Name { get; } + public int UsageBytes { get; } + public VectorStoreFileCounts FileCounts { get; } + public VectorStoreStatus Status { get; } + public DateTimeOffset? ExpiresAt { get; } + public DateTimeOffset? LastActiveAt { get; } + public IReadOnlyDictionary Metadata { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreBatchFileJob.Serialization.cs b/src/Generated/Models/VectorStoreBatchFileJob.Serialization.cs index bdfa594c..4f4fdab1 100644 --- a/src/Generated/Models/VectorStoreBatchFileJob.Serialization.cs +++ b/src/Generated/Models/VectorStoreBatchFileJob.Serialization.cs @@ -8,188 +8,187 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreBatchFileJob : IJsonModel { - public partial class VectorStoreBatchFileJob : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(BatchId); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteObjectValue(Object, options); - } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) - { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("vector_store_id") != true) - { - writer.WritePropertyName("vector_store_id"u8); - writer.WriteStringValue(VectorStoreId); - } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) - { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("file_counts") != true) - { - writer.WritePropertyName("file_counts"u8); - writer.WriteObjectValue(FileCounts, options); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(BatchId); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteObjectValue(Object, options); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("vector_store_id") != true) + { + writer.WritePropertyName("vector_store_id"u8); + writer.WriteStringValue(VectorStoreId); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("file_counts") != true) + { + writer.WritePropertyName("file_counts"u8); + writer.WriteObjectValue(FileCounts, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreBatchFileJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreBatchFileJob IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreBatchFileJob(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support reading '{format}' format."); } - internal static VectorStoreBatchFileJob DeserializeVectorStoreBatchFileJob(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreBatchFileJob(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static VectorStoreBatchFileJob DeserializeVectorStoreBatchFileJob(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + object @object = default; + DateTimeOffset createdAt = default; + string vectorStoreId = default; + VectorStoreBatchFileJobStatus status = default; + VectorStoreFileCounts fileCounts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - object @object = default; - DateTimeOffset createdAt = default; - string vectorStoreId = default; - VectorStoreBatchFileJobStatus status = default; - VectorStoreFileCounts fileCounts = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = property.Value.GetObject(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("vector_store_id"u8)) - { - vectorStoreId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = new VectorStoreBatchFileJobStatus(property.Value.GetString()); - continue; - } - if (property.NameEquals("file_counts"u8)) - { - fileCounts = VectorStoreFileCounts.DeserializeVectorStoreFileCounts(property.Value, options); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + @object = property.Value.GetObject(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreBatchFileJob( - id, - @object, - createdAt, - vectorStoreId, - status, - fileCounts, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("created_at"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support writing '{options.Format}' format."); + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; } - } - - VectorStoreBatchFileJob IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("vector_store_id"u8)) + { + vectorStoreId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new VectorStoreBatchFileJobStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("file_counts"u8)) + { + fileCounts = VectorStoreFileCounts.DeserializeVectorStoreFileCounts(property.Value, options); + continue; + } + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreBatchFileJob(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreBatchFileJob( + id, + @object, + createdAt, + vectorStoreId, + status, + fileCounts, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreBatchFileJob FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreBatchFileJob(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + VectorStoreBatchFileJob IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreBatchFileJob(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreBatchFileJob)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreBatchFileJob FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreBatchFileJob(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreBatchFileJob.cs b/src/Generated/Models/VectorStoreBatchFileJob.cs index a584a5e6..0755c988 100644 --- a/src/Generated/Models/VectorStoreBatchFileJob.cs +++ b/src/Generated/Models/VectorStoreBatchFileJob.cs @@ -5,41 +5,40 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreBatchFileJob { - public partial class VectorStoreBatchFileJob + internal IDictionary SerializedAdditionalRawData { get; set; } + internal VectorStoreBatchFileJob(string batchId, DateTimeOffset createdAt, string vectorStoreId, VectorStoreBatchFileJobStatus status, VectorStoreFileCounts fileCounts) + { + Argument.AssertNotNull(batchId, nameof(batchId)); + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileCounts, nameof(fileCounts)); + + BatchId = batchId; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + FileCounts = fileCounts; + } + + internal VectorStoreBatchFileJob(string batchId, object @object, DateTimeOffset createdAt, string vectorStoreId, VectorStoreBatchFileJobStatus status, VectorStoreFileCounts fileCounts, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal VectorStoreBatchFileJob(string batchId, DateTimeOffset createdAt, string vectorStoreId, VectorStoreBatchFileJobStatus status, VectorStoreFileCounts fileCounts) - { - Argument.AssertNotNull(batchId, nameof(batchId)); - Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(fileCounts, nameof(fileCounts)); - - BatchId = batchId; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - FileCounts = fileCounts; - } - - internal VectorStoreBatchFileJob(string batchId, object @object, DateTimeOffset createdAt, string vectorStoreId, VectorStoreBatchFileJobStatus status, VectorStoreFileCounts fileCounts, IDictionary serializedAdditionalRawData) - { - BatchId = batchId; - Object = @object; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - FileCounts = fileCounts; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal VectorStoreBatchFileJob() - { - } - - public DateTimeOffset CreatedAt { get; } - public string VectorStoreId { get; } - public VectorStoreBatchFileJobStatus Status { get; } + BatchId = batchId; + Object = @object; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + FileCounts = fileCounts; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal VectorStoreBatchFileJob() + { + } + + public DateTimeOffset CreatedAt { get; } + public string VectorStoreId { get; } + public VectorStoreBatchFileJobStatus Status { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreBatchFileJobStatus.cs b/src/Generated/Models/VectorStoreBatchFileJobStatus.cs index c4755944..303ca931 100644 --- a/src/Generated/Models/VectorStoreBatchFileJobStatus.cs +++ b/src/Generated/Models/VectorStoreBatchFileJobStatus.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public readonly partial struct VectorStoreBatchFileJobStatus : IEquatable { - public readonly partial struct VectorStoreBatchFileJobStatus : IEquatable + private readonly string _value; + + public VectorStoreBatchFileJobStatus(string value) { - private readonly string _value; - - public VectorStoreBatchFileJobStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string CompletedValue = "completed"; - private const string CancelledValue = "cancelled"; - private const string FailedValue = "failed"; - - public static VectorStoreBatchFileJobStatus InProgress { get; } = new VectorStoreBatchFileJobStatus(InProgressValue); - public static VectorStoreBatchFileJobStatus Completed { get; } = new VectorStoreBatchFileJobStatus(CompletedValue); - public static VectorStoreBatchFileJobStatus Cancelled { get; } = new VectorStoreBatchFileJobStatus(CancelledValue); - public static VectorStoreBatchFileJobStatus Failed { get; } = new VectorStoreBatchFileJobStatus(FailedValue); - public static bool operator ==(VectorStoreBatchFileJobStatus left, VectorStoreBatchFileJobStatus right) => left.Equals(right); - public static bool operator !=(VectorStoreBatchFileJobStatus left, VectorStoreBatchFileJobStatus right) => !left.Equals(right); - public static implicit operator VectorStoreBatchFileJobStatus(string value) => new VectorStoreBatchFileJobStatus(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreBatchFileJobStatus other && Equals(other); - public bool Equals(VectorStoreBatchFileJobStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + + public static VectorStoreBatchFileJobStatus InProgress { get; } = new VectorStoreBatchFileJobStatus(InProgressValue); + public static VectorStoreBatchFileJobStatus Completed { get; } = new VectorStoreBatchFileJobStatus(CompletedValue); + public static VectorStoreBatchFileJobStatus Cancelled { get; } = new VectorStoreBatchFileJobStatus(CancelledValue); + public static VectorStoreBatchFileJobStatus Failed { get; } = new VectorStoreBatchFileJobStatus(FailedValue); + public static bool operator ==(VectorStoreBatchFileJobStatus left, VectorStoreBatchFileJobStatus right) => left.Equals(right); + public static bool operator !=(VectorStoreBatchFileJobStatus left, VectorStoreBatchFileJobStatus right) => !left.Equals(right); + public static implicit operator VectorStoreBatchFileJobStatus(string value) => new VectorStoreBatchFileJobStatus(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreBatchFileJobStatus other && Equals(other); + public bool Equals(VectorStoreBatchFileJobStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreCollectionOrder.cs b/src/Generated/Models/VectorStoreCollectionOrder.cs index d8e01932..83cf92c5 100644 --- a/src/Generated/Models/VectorStoreCollectionOrder.cs +++ b/src/Generated/Models/VectorStoreCollectionOrder.cs @@ -5,29 +5,28 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public readonly partial struct VectorStoreCollectionOrder : IEquatable { - public readonly partial struct VectorStoreCollectionOrder : IEquatable + private readonly string _value; + + public VectorStoreCollectionOrder(string value) { - private readonly string _value; - - public VectorStoreCollectionOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AscendingValue = "asc"; - private const string DescendingValue = "desc"; - public static bool operator ==(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right) => left.Equals(right); - public static bool operator !=(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right) => !left.Equals(right); - public static implicit operator VectorStoreCollectionOrder(string value) => new VectorStoreCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreCollectionOrder other && Equals(other); - public bool Equals(VectorStoreCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AscendingValue = "asc"; + private const string DescendingValue = "desc"; + public static bool operator ==(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right) => left.Equals(right); + public static bool operator !=(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right) => !left.Equals(right); + public static implicit operator VectorStoreCollectionOrder(string value) => new VectorStoreCollectionOrder(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreCollectionOrder other && Equals(other); + public bool Equals(VectorStoreCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreCreationHelper.Serialization.cs b/src/Generated/Models/VectorStoreCreationHelper.Serialization.cs index 3004632e..e9069c58 100644 --- a/src/Generated/Models/VectorStoreCreationHelper.Serialization.cs +++ b/src/Generated/Models/VectorStoreCreationHelper.Serialization.cs @@ -9,181 +9,180 @@ using System.Text.Json; using OpenAI.VectorStores; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class VectorStoreCreationHelper : IJsonModel { - public partial class VectorStoreCreationHelper : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } - if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + writer.WriteEndObject(); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); + continue; } - writer.WriteEndObject(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreCreationHelper IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreCreationHelper IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreCreationHelper(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support reading '{format}' format."); } - internal static VectorStoreCreationHelper DeserializeVectorStoreCreationHelper(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreCreationHelper(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - FileChunkingStrategy chunkingStrategy = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static VectorStoreCreationHelper DeserializeVectorStoreCreationHelper(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + FileChunkingStrategy chunkingStrategy = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (property.NameEquals("chunking_strategy"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); continue; } - if (property.NameEquals("metadata"u8)) + chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreCreationHelper(fileIds ?? new ChangeTrackingList(), chunkingStrategy, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreCreationHelper(fileIds ?? new ChangeTrackingList(), chunkingStrategy, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - VectorStoreCreationHelper IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreCreationHelper(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + VectorStoreCreationHelper IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreCreationHelper FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreCreationHelper(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreCreationHelper(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreCreationHelper)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreCreationHelper FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreCreationHelper(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreCreationHelper.cs b/src/Generated/Models/VectorStoreCreationHelper.cs index 6871ab91..e471fb24 100644 --- a/src/Generated/Models/VectorStoreCreationHelper.cs +++ b/src/Generated/Models/VectorStoreCreationHelper.cs @@ -6,26 +6,25 @@ using System.Collections.Generic; using OpenAI.VectorStores; -namespace OpenAI.Assistants +namespace OpenAI.Assistants; + +public partial class VectorStoreCreationHelper { - public partial class VectorStoreCreationHelper + internal IDictionary SerializedAdditionalRawData { get; set; } + public VectorStoreCreationHelper() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public VectorStoreCreationHelper() - { - FileIds = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - internal VectorStoreCreationHelper(IList fileIds, FileChunkingStrategy chunkingStrategy, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - ChunkingStrategy = chunkingStrategy; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } - public IList FileIds { get; } - public IDictionary Metadata { get; } + internal VectorStoreCreationHelper(IList fileIds, FileChunkingStrategy chunkingStrategy, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + ChunkingStrategy = chunkingStrategy; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList FileIds { get; } + public IDictionary Metadata { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs b/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs index 4b08b506..d1e5d75d 100644 --- a/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs +++ b/src/Generated/Models/VectorStoreCreationOptions.Serialization.cs @@ -8,220 +8,219 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreCreationOptions : IJsonModel { - public partial class VectorStoreCreationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support writing '{format}' format."); + writer.WriteStringValue(item); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("file_ids") != true && Optional.IsCollectionDefined(FileIds)) + writer.WriteEndArray(); + } + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (SerializedAdditionalRawData?.ContainsKey("expires_after") != true && Optional.IsDefined(ExpirationPolicy)) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpirationPolicy, options); + } + if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteStringValue(item); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } - writer.WriteEndArray(); + writer.WriteEndObject(); } - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + else { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); + writer.WriteNull("metadata"); } - if (SerializedAdditionalRawData?.ContainsKey("expires_after") != true && Optional.IsDefined(ExpirationPolicy)) - { - writer.WritePropertyName("expires_after"u8); - writer.WriteObjectValue(ExpirationPolicy, options); - } - if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) - { - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); - } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("metadata"); + continue; } - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreCreationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support reading '{format}' format."); } - internal static VectorStoreCreationOptions DeserializeVectorStoreCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreCreationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList fileIds = default; - string name = default; - VectorStoreExpirationPolicy expiresAfter = default; - FileChunkingStrategy chunkingStrategy = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static VectorStoreCreationOptions DeserializeVectorStoreCreationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + string name = default; + VectorStoreExpirationPolicy expiresAfter = default; + FileChunkingStrategy chunkingStrategy = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) { - if (property.NameEquals("file_ids"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; continue; } - if (property.NameEquals("name"u8)) + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) { - name = property.Value.GetString(); - continue; + array.Add(item.GetString()); } - if (property.NameEquals("expires_after"u8)) + fileIds = array; + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); continue; } - if (property.NameEquals("chunking_strategy"u8)) + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); continue; } - if (property.NameEquals("metadata"u8)) + chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreCreationOptions( - fileIds ?? new ChangeTrackingList(), - name, - expiresAfter, - chunkingStrategy, - metadata ?? new ChangeTrackingDictionary(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreCreationOptions( + fileIds ?? new ChangeTrackingList(), + name, + expiresAfter, + chunkingStrategy, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } - VectorStoreCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreCreationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + VectorStoreCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreCreationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreCreationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreCreationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreCreationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreCreationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreCreationOptions.cs b/src/Generated/Models/VectorStoreCreationOptions.cs index 6d5f3121..5b0db656 100644 --- a/src/Generated/Models/VectorStoreCreationOptions.cs +++ b/src/Generated/Models/VectorStoreCreationOptions.cs @@ -5,29 +5,28 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreCreationOptions { - public partial class VectorStoreCreationOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public VectorStoreCreationOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public VectorStoreCreationOptions() - { - FileIds = new ChangeTrackingList(); - Metadata = new ChangeTrackingDictionary(); - } - - internal VectorStoreCreationOptions(IList fileIds, string name, VectorStoreExpirationPolicy expirationPolicy, FileChunkingStrategy chunkingStrategy, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - FileIds = fileIds; - Name = name; - ExpirationPolicy = expirationPolicy; - ChunkingStrategy = chunkingStrategy; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } - public IList FileIds { get; } - public string Name { get; set; } - public IDictionary Metadata { get; set; } + internal VectorStoreCreationOptions(IList fileIds, string name, VectorStoreExpirationPolicy expirationPolicy, FileChunkingStrategy chunkingStrategy, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + Name = name; + ExpirationPolicy = expirationPolicy; + ChunkingStrategy = chunkingStrategy; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public IList FileIds { get; } + public string Name { get; set; } + public IDictionary Metadata { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreDeletionResult.Serialization.cs b/src/Generated/Models/VectorStoreDeletionResult.Serialization.cs index 2504be9d..071c872b 100644 --- a/src/Generated/Models/VectorStoreDeletionResult.Serialization.cs +++ b/src/Generated/Models/VectorStoreDeletionResult.Serialization.cs @@ -8,148 +8,147 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreDeletionResult : IJsonModel { - public partial class VectorStoreDeletionResult : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(VectorStoreId); - } - if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) - { - writer.WritePropertyName("deleted"u8); - writer.WriteBooleanValue(Deleted); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(VectorStoreId); + } + if (SerializedAdditionalRawData?.ContainsKey("deleted") != true) + { + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreDeletionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreDeletionResult(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support reading '{format}' format."); } - internal static VectorStoreDeletionResult DeserializeVectorStoreDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreDeletionResult(document.RootElement, options); + } + + internal static VectorStoreDeletionResult DeserializeVectorStoreDeletionResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + InternalDeleteVectorStoreResponseObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - bool deleted = default; - InternalDeleteVectorStoreResponseObject @object = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("deleted"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("deleted"u8)) - { - deleted = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalDeleteVectorStoreResponseObject(property.Value.GetString()); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + deleted = property.Value.GetBoolean(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreDeletionResult(id, deleted, @object, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("object"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support writing '{options.Format}' format."); + @object = new InternalDeleteVectorStoreResponseObject(property.Value.GetString()); + continue; } - } - - VectorStoreDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreDeletionResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support reading '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreDeletionResult(id, deleted, @object, serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreDeletionResult FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreDeletionResult(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support writing '{options.Format}' format."); } + } + + VectorStoreDeletionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal virtual BinaryContent ToBinaryContent() + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreDeletionResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreDeletionResult)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreDeletionResult FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreDeletionResult(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreDeletionResult.cs b/src/Generated/Models/VectorStoreDeletionResult.cs index 1e046bda..f3ef50ab 100644 --- a/src/Generated/Models/VectorStoreDeletionResult.cs +++ b/src/Generated/Models/VectorStoreDeletionResult.cs @@ -5,30 +5,29 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreDeletionResult { - public partial class VectorStoreDeletionResult + internal IDictionary SerializedAdditionalRawData { get; set; } + internal VectorStoreDeletionResult(string vectorStoreId, bool deleted) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal VectorStoreDeletionResult(string vectorStoreId, bool deleted) - { - Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); - VectorStoreId = vectorStoreId; - Deleted = deleted; - } + VectorStoreId = vectorStoreId; + Deleted = deleted; + } - internal VectorStoreDeletionResult(string vectorStoreId, bool deleted, InternalDeleteVectorStoreResponseObject @object, IDictionary serializedAdditionalRawData) - { - VectorStoreId = vectorStoreId; - Deleted = deleted; - Object = @object; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal VectorStoreDeletionResult(string vectorStoreId, bool deleted, InternalDeleteVectorStoreResponseObject @object, IDictionary serializedAdditionalRawData) + { + VectorStoreId = vectorStoreId; + Deleted = deleted; + Object = @object; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal VectorStoreDeletionResult() - { - } - public bool Deleted { get; } + internal VectorStoreDeletionResult() + { } -} + public bool Deleted { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreExpirationAnchor.Serialization.cs b/src/Generated/Models/VectorStoreExpirationAnchor.Serialization.cs index 90af403e..019430a2 100644 --- a/src/Generated/Models/VectorStoreExpirationAnchor.Serialization.cs +++ b/src/Generated/Models/VectorStoreExpirationAnchor.Serialization.cs @@ -4,20 +4,19 @@ using System; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal static partial class VectorStoreExpirationAnchorExtensions { - internal static partial class VectorStoreExpirationAnchorExtensions + public static string ToSerialString(this VectorStoreExpirationAnchor value) => value switch { - public static string ToSerialString(this VectorStoreExpirationAnchor value) => value switch - { - VectorStoreExpirationAnchor.LastActiveAt => "last_active_at", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreExpirationAnchor value.") - }; + VectorStoreExpirationAnchor.LastActiveAt => "last_active_at", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreExpirationAnchor value.") + }; - public static VectorStoreExpirationAnchor ToVectorStoreExpirationAnchor(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "last_active_at")) return VectorStoreExpirationAnchor.LastActiveAt; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreExpirationAnchor value."); - } + public static VectorStoreExpirationAnchor ToVectorStoreExpirationAnchor(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "last_active_at")) return VectorStoreExpirationAnchor.LastActiveAt; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreExpirationAnchor value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreExpirationPolicy.Serialization.cs b/src/Generated/Models/VectorStoreExpirationPolicy.Serialization.cs index 76b1d5d3..abfc6fb9 100644 --- a/src/Generated/Models/VectorStoreExpirationPolicy.Serialization.cs +++ b/src/Generated/Models/VectorStoreExpirationPolicy.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreExpirationPolicy : IJsonModel { - public partial class VectorStoreExpirationPolicy : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("anchor") != true) - { - writer.WritePropertyName("anchor"u8); - writer.WriteStringValue(_anchor.ToSerialString()); - } - if (SerializedAdditionalRawData?.ContainsKey("days") != true) - { - writer.WritePropertyName("days"u8); - writer.WriteNumberValue(_days); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("anchor") != true) + { + writer.WritePropertyName("anchor"u8); + writer.WriteStringValue(_anchor.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("days") != true) + { + writer.WritePropertyName("days"u8); + writer.WriteNumberValue(_days); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreExpirationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreExpirationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{format}' format."); } - internal static VectorStoreExpirationPolicy DeserializeVectorStoreExpirationPolicy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); + } + + internal static VectorStoreExpirationPolicy DeserializeVectorStoreExpirationPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreExpirationAnchor anchor = default; + int days = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("anchor"u8)) { - return null; + anchor = property.Value.GetString().ToVectorStoreExpirationAnchor(); + continue; } - VectorStoreExpirationAnchor anchor = default; - int days = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("days"u8)) { - if (property.NameEquals("anchor"u8)) - { - anchor = property.Value.GetString().ToVectorStoreExpirationAnchor(); - continue; - } - if (property.NameEquals("days"u8)) - { - days = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + days = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreExpirationPolicy(anchor, days, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreExpirationPolicy(anchor, days, serializedAdditionalRawData); + } - VectorStoreExpirationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + VectorStoreExpirationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreExpirationPolicy FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreExpirationPolicy(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreExpirationPolicy FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreExpirationPolicy(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreExpirationPolicy.cs b/src/Generated/Models/VectorStoreExpirationPolicy.cs index 3fd71c7e..77ecb6c6 100644 --- a/src/Generated/Models/VectorStoreExpirationPolicy.cs +++ b/src/Generated/Models/VectorStoreExpirationPolicy.cs @@ -5,9 +5,8 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreExpirationPolicy { - public partial class VectorStoreExpirationPolicy - { - } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs b/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs index ede8e0d5..375023c6 100644 --- a/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs +++ b/src/Generated/Models/VectorStoreFileAssociation.Serialization.cs @@ -8,228 +8,227 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreFileAssociation : IJsonModel { - public partial class VectorStoreFileAssociation : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("id") != true) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(FileId); - } - if (SerializedAdditionalRawData?.ContainsKey("object") != true) - { - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("usage_bytes") != true) - { - writer.WritePropertyName("usage_bytes"u8); - writer.WriteNumberValue(Size); - } - if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) - { - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - } - if (SerializedAdditionalRawData?.ContainsKey("vector_store_id") != true) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("id") != true) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(FileId); + } + if (SerializedAdditionalRawData?.ContainsKey("object") != true) + { + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("usage_bytes") != true) + { + writer.WritePropertyName("usage_bytes"u8); + writer.WriteNumberValue(Size); + } + if (SerializedAdditionalRawData?.ContainsKey("created_at") != true) + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + } + if (SerializedAdditionalRawData?.ContainsKey("vector_store_id") != true) + { + writer.WritePropertyName("vector_store_id"u8); + writer.WriteStringValue(VectorStoreId); + } + if (SerializedAdditionalRawData?.ContainsKey("status") != true) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToSerialString()); + } + if (SerializedAdditionalRawData?.ContainsKey("last_error") != true) + { + if (LastError != null) { - writer.WritePropertyName("vector_store_id"u8); - writer.WriteStringValue(VectorStoreId); + writer.WritePropertyName("last_error"u8); + writer.WriteObjectValue(LastError, options); } - if (SerializedAdditionalRawData?.ContainsKey("status") != true) + else { - writer.WritePropertyName("status"u8); - writer.WriteStringValue(Status.ToSerialString()); + writer.WriteNull("last_error"); } - if (SerializedAdditionalRawData?.ContainsKey("last_error") != true) + } + if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - if (LastError != null) - { - writer.WritePropertyName("last_error"u8); - writer.WriteObjectValue(LastError, options); - } - else + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - writer.WriteNull("last_error"); + continue; } - } - if (SerializedAdditionalRawData?.ContainsKey("chunking_strategy") != true && Optional.IsDefined(ChunkingStrategy)) - { - writer.WritePropertyName("chunking_strategy"u8); - writer.WriteObjectValue(ChunkingStrategy, options); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreFileAssociation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreFileAssociation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFileAssociation(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support reading '{format}' format."); } - internal static VectorStoreFileAssociation DeserializeVectorStoreFileAssociation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileAssociation(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) + internal static VectorStoreFileAssociation DeserializeVectorStoreFileAssociation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InternalVectorStoreFileObjectObject @object = default; + int usageBytes = default; + DateTimeOffset createdAt = default; + string vectorStoreId = default; + VectorStoreFileAssociationStatus status = default; + VectorStoreFileAssociationError lastError = default; + FileChunkingStrategy chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) { - return null; + id = property.Value.GetString(); + continue; } - string id = default; - InternalVectorStoreFileObjectObject @object = default; - int usageBytes = default; - DateTimeOffset createdAt = default; - string vectorStoreId = default; - VectorStoreFileAssociationStatus status = default; - VectorStoreFileAssociationError lastError = default; - FileChunkingStrategy chunkingStrategy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("object"u8)) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) - { - @object = new InternalVectorStoreFileObjectObject(property.Value.GetString()); - continue; - } - if (property.NameEquals("usage_bytes"u8)) - { - usageBytes = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("vector_store_id"u8)) - { - vectorStoreId = property.Value.GetString(); - continue; - } - if (property.NameEquals("status"u8)) - { - status = property.Value.GetString().ToVectorStoreFileAssociationStatus(); - continue; - } - if (property.NameEquals("last_error"u8)) + @object = new InternalVectorStoreFileObjectObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage_bytes"u8)) + { + usageBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("vector_store_id"u8)) + { + vectorStoreId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString().ToVectorStoreFileAssociationStatus(); + continue; + } + if (property.NameEquals("last_error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - lastError = null; - continue; - } - lastError = VectorStoreFileAssociationError.DeserializeVectorStoreFileAssociationError(property.Value, options); + lastError = null; continue; } - if (property.NameEquals("chunking_strategy"u8)) + lastError = VectorStoreFileAssociationError.DeserializeVectorStoreFileAssociationError(property.Value, options); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); continue; } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + chunkingStrategy = FileChunkingStrategy.DeserializeFileChunkingStrategy(property.Value, options); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFileAssociation( - id, - @object, - usageBytes, - createdAt, - vectorStoreId, - status, - lastError, - chunkingStrategy, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileAssociation( + id, + @object, + usageBytes, + createdAt, + vectorStoreId, + status, + lastError, + chunkingStrategy, + serializedAdditionalRawData); + } - VectorStoreFileAssociation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreFileAssociation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + VectorStoreFileAssociation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreFileAssociation FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreFileAssociation(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFileAssociation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileAssociation)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreFileAssociation FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFileAssociation(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileAssociation.cs b/src/Generated/Models/VectorStoreFileAssociation.cs index c7da0b02..3d7056c2 100644 --- a/src/Generated/Models/VectorStoreFileAssociation.cs +++ b/src/Generated/Models/VectorStoreFileAssociation.cs @@ -5,43 +5,42 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreFileAssociation { - public partial class VectorStoreFileAssociation + internal IDictionary SerializedAdditionalRawData { get; set; } + internal VectorStoreFileAssociation(string fileId, int size, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileAssociationStatus status, VectorStoreFileAssociationError lastError) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal VectorStoreFileAssociation(string fileId, int size, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileAssociationStatus status, VectorStoreFileAssociationError lastError) - { - Argument.AssertNotNull(fileId, nameof(fileId)); - Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); - FileId = fileId; - Size = size; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - LastError = lastError; - } + FileId = fileId; + Size = size; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + LastError = lastError; + } - internal VectorStoreFileAssociation(string fileId, InternalVectorStoreFileObjectObject @object, int size, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileAssociationStatus status, VectorStoreFileAssociationError lastError, FileChunkingStrategy chunkingStrategy, IDictionary serializedAdditionalRawData) - { - FileId = fileId; - Object = @object; - Size = size; - CreatedAt = createdAt; - VectorStoreId = vectorStoreId; - Status = status; - LastError = lastError; - ChunkingStrategy = chunkingStrategy; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + internal VectorStoreFileAssociation(string fileId, InternalVectorStoreFileObjectObject @object, int size, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileAssociationStatus status, VectorStoreFileAssociationError lastError, FileChunkingStrategy chunkingStrategy, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Object = @object; + Size = size; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + LastError = lastError; + ChunkingStrategy = chunkingStrategy; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - internal VectorStoreFileAssociation() - { - } - public DateTimeOffset CreatedAt { get; } - public string VectorStoreId { get; } - public VectorStoreFileAssociationStatus Status { get; } - public VectorStoreFileAssociationError LastError { get; } + internal VectorStoreFileAssociation() + { } -} + public DateTimeOffset CreatedAt { get; } + public string VectorStoreId { get; } + public VectorStoreFileAssociationStatus Status { get; } + public VectorStoreFileAssociationError LastError { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileAssociationCollectionOrder.cs b/src/Generated/Models/VectorStoreFileAssociationCollectionOrder.cs index 02656b21..aba3e8ff 100644 --- a/src/Generated/Models/VectorStoreFileAssociationCollectionOrder.cs +++ b/src/Generated/Models/VectorStoreFileAssociationCollectionOrder.cs @@ -5,29 +5,28 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public readonly partial struct VectorStoreFileAssociationCollectionOrder : IEquatable { - public readonly partial struct VectorStoreFileAssociationCollectionOrder : IEquatable + private readonly string _value; + + public VectorStoreFileAssociationCollectionOrder(string value) { - private readonly string _value; - - public VectorStoreFileAssociationCollectionOrder(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AscendingValue = "asc"; - private const string DescendingValue = "desc"; - public static bool operator ==(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right) => left.Equals(right); - public static bool operator !=(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right) => !left.Equals(right); - public static implicit operator VectorStoreFileAssociationCollectionOrder(string value) => new VectorStoreFileAssociationCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileAssociationCollectionOrder other && Equals(other); - public bool Equals(VectorStoreFileAssociationCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string AscendingValue = "asc"; + private const string DescendingValue = "desc"; + public static bool operator ==(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right) => left.Equals(right); + public static bool operator !=(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right) => !left.Equals(right); + public static implicit operator VectorStoreFileAssociationCollectionOrder(string value) => new VectorStoreFileAssociationCollectionOrder(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileAssociationCollectionOrder other && Equals(other); + public bool Equals(VectorStoreFileAssociationCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileAssociationError.Serialization.cs b/src/Generated/Models/VectorStoreFileAssociationError.Serialization.cs index 9bc7e212..332365a3 100644 --- a/src/Generated/Models/VectorStoreFileAssociationError.Serialization.cs +++ b/src/Generated/Models/VectorStoreFileAssociationError.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreFileAssociationError : IJsonModel { - public partial class VectorStoreFileAssociationError : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("code") != true) - { - writer.WritePropertyName("code"u8); - writer.WriteStringValue(Code.ToString()); - } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) - { - writer.WritePropertyName("message"u8); - writer.WriteStringValue(Message); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("code") != true) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + } + if (SerializedAdditionalRawData?.ContainsKey("message") != true) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreFileAssociationError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreFileAssociationError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFileAssociationError(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support reading '{format}' format."); } - internal static VectorStoreFileAssociationError DeserializeVectorStoreFileAssociationError(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileAssociationError(document.RootElement, options); + } + + internal static VectorStoreFileAssociationError DeserializeVectorStoreFileAssociationError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreFileAssociationErrorCode code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) { - return null; + code = new VectorStoreFileAssociationErrorCode(property.Value.GetString()); + continue; } - VectorStoreFileAssociationErrorCode code = default; - string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("message"u8)) { - if (property.NameEquals("code"u8)) - { - code = new VectorStoreFileAssociationErrorCode(property.Value.GetString()); - continue; - } - if (property.NameEquals("message"u8)) - { - message = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + message = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFileAssociationError(code, message, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileAssociationError(code, message, serializedAdditionalRawData); + } - VectorStoreFileAssociationError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreFileAssociationError(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + VectorStoreFileAssociationError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreFileAssociationError FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreFileAssociationError(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFileAssociationError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileAssociationError)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreFileAssociationError FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFileAssociationError(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileAssociationError.cs b/src/Generated/Models/VectorStoreFileAssociationError.cs index 638e7f52..a251f3fc 100644 --- a/src/Generated/Models/VectorStoreFileAssociationError.cs +++ b/src/Generated/Models/VectorStoreFileAssociationError.cs @@ -5,31 +5,30 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreFileAssociationError { - public partial class VectorStoreFileAssociationError + internal IDictionary SerializedAdditionalRawData { get; set; } + internal VectorStoreFileAssociationError(VectorStoreFileAssociationErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + } + + internal VectorStoreFileAssociationError(VectorStoreFileAssociationErrorCode code, string message, IDictionary serializedAdditionalRawData) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal VectorStoreFileAssociationError(VectorStoreFileAssociationErrorCode code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - } - - internal VectorStoreFileAssociationError(VectorStoreFileAssociationErrorCode code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - internal VectorStoreFileAssociationError() - { - } - - public VectorStoreFileAssociationErrorCode Code { get; } - public string Message { get; } + Code = code; + Message = message; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + internal VectorStoreFileAssociationError() + { + } + + public VectorStoreFileAssociationErrorCode Code { get; } + public string Message { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileAssociationErrorCode.cs b/src/Generated/Models/VectorStoreFileAssociationErrorCode.cs index 167ad6b2..c22b52f2 100644 --- a/src/Generated/Models/VectorStoreFileAssociationErrorCode.cs +++ b/src/Generated/Models/VectorStoreFileAssociationErrorCode.cs @@ -5,34 +5,33 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public readonly partial struct VectorStoreFileAssociationErrorCode : IEquatable { - public readonly partial struct VectorStoreFileAssociationErrorCode : IEquatable + private readonly string _value; + + public VectorStoreFileAssociationErrorCode(string value) { - private readonly string _value; - - public VectorStoreFileAssociationErrorCode(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ServerErrorValue = "server_error"; - private const string UnsupportedFileValue = "unsupported_file"; - private const string InvalidFileValue = "invalid_file"; - - public static VectorStoreFileAssociationErrorCode ServerError { get; } = new VectorStoreFileAssociationErrorCode(ServerErrorValue); - public static VectorStoreFileAssociationErrorCode UnsupportedFile { get; } = new VectorStoreFileAssociationErrorCode(UnsupportedFileValue); - public static VectorStoreFileAssociationErrorCode InvalidFile { get; } = new VectorStoreFileAssociationErrorCode(InvalidFileValue); - public static bool operator ==(VectorStoreFileAssociationErrorCode left, VectorStoreFileAssociationErrorCode right) => left.Equals(right); - public static bool operator !=(VectorStoreFileAssociationErrorCode left, VectorStoreFileAssociationErrorCode right) => !left.Equals(right); - public static implicit operator VectorStoreFileAssociationErrorCode(string value) => new VectorStoreFileAssociationErrorCode(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileAssociationErrorCode other && Equals(other); - public bool Equals(VectorStoreFileAssociationErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string ServerErrorValue = "server_error"; + private const string UnsupportedFileValue = "unsupported_file"; + private const string InvalidFileValue = "invalid_file"; + + public static VectorStoreFileAssociationErrorCode ServerError { get; } = new VectorStoreFileAssociationErrorCode(ServerErrorValue); + public static VectorStoreFileAssociationErrorCode UnsupportedFile { get; } = new VectorStoreFileAssociationErrorCode(UnsupportedFileValue); + public static VectorStoreFileAssociationErrorCode InvalidFile { get; } = new VectorStoreFileAssociationErrorCode(InvalidFileValue); + public static bool operator ==(VectorStoreFileAssociationErrorCode left, VectorStoreFileAssociationErrorCode right) => left.Equals(right); + public static bool operator !=(VectorStoreFileAssociationErrorCode left, VectorStoreFileAssociationErrorCode right) => !left.Equals(right); + public static implicit operator VectorStoreFileAssociationErrorCode(string value) => new VectorStoreFileAssociationErrorCode(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileAssociationErrorCode other && Equals(other); + public bool Equals(VectorStoreFileAssociationErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileAssociationStatus.Serialization.cs b/src/Generated/Models/VectorStoreFileAssociationStatus.Serialization.cs index fc493ac6..97794c55 100644 --- a/src/Generated/Models/VectorStoreFileAssociationStatus.Serialization.cs +++ b/src/Generated/Models/VectorStoreFileAssociationStatus.Serialization.cs @@ -4,26 +4,25 @@ using System; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal static partial class VectorStoreFileAssociationStatusExtensions { - internal static partial class VectorStoreFileAssociationStatusExtensions + public static string ToSerialString(this VectorStoreFileAssociationStatus value) => value switch { - public static string ToSerialString(this VectorStoreFileAssociationStatus value) => value switch - { - VectorStoreFileAssociationStatus.InProgress => "in_progress", - VectorStoreFileAssociationStatus.Completed => "completed", - VectorStoreFileAssociationStatus.Cancelled => "cancelled", - VectorStoreFileAssociationStatus.Failed => "failed", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreFileAssociationStatus value.") - }; + VectorStoreFileAssociationStatus.InProgress => "in_progress", + VectorStoreFileAssociationStatus.Completed => "completed", + VectorStoreFileAssociationStatus.Cancelled => "cancelled", + VectorStoreFileAssociationStatus.Failed => "failed", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreFileAssociationStatus value.") + }; - public static VectorStoreFileAssociationStatus ToVectorStoreFileAssociationStatus(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "in_progress")) return VectorStoreFileAssociationStatus.InProgress; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "completed")) return VectorStoreFileAssociationStatus.Completed; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "cancelled")) return VectorStoreFileAssociationStatus.Cancelled; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "failed")) return VectorStoreFileAssociationStatus.Failed; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreFileAssociationStatus value."); - } + public static VectorStoreFileAssociationStatus ToVectorStoreFileAssociationStatus(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "in_progress")) return VectorStoreFileAssociationStatus.InProgress; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "completed")) return VectorStoreFileAssociationStatus.Completed; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "cancelled")) return VectorStoreFileAssociationStatus.Cancelled; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "failed")) return VectorStoreFileAssociationStatus.Failed; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreFileAssociationStatus value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileCounts.Serialization.cs b/src/Generated/Models/VectorStoreFileCounts.Serialization.cs index 0a4998a0..a67201df 100644 --- a/src/Generated/Models/VectorStoreFileCounts.Serialization.cs +++ b/src/Generated/Models/VectorStoreFileCounts.Serialization.cs @@ -8,176 +8,175 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreFileCounts : IJsonModel { - public partial class VectorStoreFileCounts : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("in_progress") != true) - { - writer.WritePropertyName("in_progress"u8); - writer.WriteNumberValue(InProgress); - } - if (SerializedAdditionalRawData?.ContainsKey("completed") != true) - { - writer.WritePropertyName("completed"u8); - writer.WriteNumberValue(Completed); - } - if (SerializedAdditionalRawData?.ContainsKey("failed") != true) - { - writer.WritePropertyName("failed"u8); - writer.WriteNumberValue(Failed); - } - if (SerializedAdditionalRawData?.ContainsKey("cancelled") != true) - { - writer.WritePropertyName("cancelled"u8); - writer.WriteNumberValue(Cancelled); - } - if (SerializedAdditionalRawData?.ContainsKey("total") != true) - { - writer.WritePropertyName("total"u8); - writer.WriteNumberValue(Total); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("in_progress") != true) + { + writer.WritePropertyName("in_progress"u8); + writer.WriteNumberValue(InProgress); + } + if (SerializedAdditionalRawData?.ContainsKey("completed") != true) + { + writer.WritePropertyName("completed"u8); + writer.WriteNumberValue(Completed); + } + if (SerializedAdditionalRawData?.ContainsKey("failed") != true) + { + writer.WritePropertyName("failed"u8); + writer.WriteNumberValue(Failed); + } + if (SerializedAdditionalRawData?.ContainsKey("cancelled") != true) + { + writer.WritePropertyName("cancelled"u8); + writer.WriteNumberValue(Cancelled); + } + if (SerializedAdditionalRawData?.ContainsKey("total") != true) + { + writer.WritePropertyName("total"u8); + writer.WriteNumberValue(Total); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreFileCounts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreFileCounts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreFileCounts(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support reading '{format}' format."); } - internal static VectorStoreFileCounts DeserializeVectorStoreFileCounts(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileCounts(document.RootElement, options); + } + + internal static VectorStoreFileCounts DeserializeVectorStoreFileCounts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int inProgress = default; + int completed = default; + int failed = default; + int cancelled = default; + int total = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("in_progress"u8)) { - return null; + inProgress = property.Value.GetInt32(); + continue; } - int inProgress = default; - int completed = default; - int failed = default; - int cancelled = default; - int total = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("completed"u8)) { - if (property.NameEquals("in_progress"u8)) - { - inProgress = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("completed"u8)) - { - completed = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("failed"u8)) - { - failed = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("cancelled"u8)) - { - cancelled = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("total"u8)) - { - total = property.Value.GetInt32(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + completed = property.Value.GetInt32(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreFileCounts( - inProgress, - completed, - failed, - cancelled, - total, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("failed"u8)) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support writing '{options.Format}' format."); + failed = property.Value.GetInt32(); + continue; } - } - - VectorStoreFileCounts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (property.NameEquals("cancelled"u8)) { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreFileCounts(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support reading '{options.Format}' format."); + cancelled = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("total"u8)) + { + total = property.Value.GetInt32(); + continue; + } + if (true) + { + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileCounts( + inProgress, + completed, + failed, + cancelled, + total, + serializedAdditionalRawData); + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreFileCounts FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreFileCounts(document.RootElement); + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support writing '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() + VectorStoreFileCounts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFileCounts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileCounts)} does not support reading '{options.Format}' format."); } } -} + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreFileCounts FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFileCounts(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileCounts.cs b/src/Generated/Models/VectorStoreFileCounts.cs index 7d35eacc..0616a671 100644 --- a/src/Generated/Models/VectorStoreFileCounts.cs +++ b/src/Generated/Models/VectorStoreFileCounts.cs @@ -5,38 +5,37 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreFileCounts { - public partial class VectorStoreFileCounts + internal IDictionary SerializedAdditionalRawData { get; set; } + internal VectorStoreFileCounts(int inProgress, int completed, int failed, int cancelled, int total) { - internal IDictionary SerializedAdditionalRawData { get; set; } - internal VectorStoreFileCounts(int inProgress, int completed, int failed, int cancelled, int total) - { - InProgress = inProgress; - Completed = completed; - Failed = failed; - Cancelled = cancelled; - Total = total; - } - - internal VectorStoreFileCounts(int inProgress, int completed, int failed, int cancelled, int total, IDictionary serializedAdditionalRawData) - { - InProgress = inProgress; - Completed = completed; - Failed = failed; - Cancelled = cancelled; - Total = total; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + } - internal VectorStoreFileCounts() - { - } + internal VectorStoreFileCounts(int inProgress, int completed, int failed, int cancelled, int total, IDictionary serializedAdditionalRawData) + { + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + SerializedAdditionalRawData = serializedAdditionalRawData; + } - public int InProgress { get; } - public int Completed { get; } - public int Failed { get; } - public int Cancelled { get; } - public int Total { get; } + internal VectorStoreFileCounts() + { } -} + + public int InProgress { get; } + public int Completed { get; } + public int Failed { get; } + public int Cancelled { get; } + public int Total { get; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreFileStatusFilter.cs b/src/Generated/Models/VectorStoreFileStatusFilter.cs index 762b7f10..6cfe3b85 100644 --- a/src/Generated/Models/VectorStoreFileStatusFilter.cs +++ b/src/Generated/Models/VectorStoreFileStatusFilter.cs @@ -5,36 +5,35 @@ using System; using System.ComponentModel; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public readonly partial struct VectorStoreFileStatusFilter : IEquatable { - public readonly partial struct VectorStoreFileStatusFilter : IEquatable + private readonly string _value; + + public VectorStoreFileStatusFilter(string value) { - private readonly string _value; - - public VectorStoreFileStatusFilter(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string InProgressValue = "in_progress"; - private const string CompletedValue = "completed"; - private const string FailedValue = "failed"; - private const string CancelledValue = "cancelled"; - - public static VectorStoreFileStatusFilter InProgress { get; } = new VectorStoreFileStatusFilter(InProgressValue); - public static VectorStoreFileStatusFilter Completed { get; } = new VectorStoreFileStatusFilter(CompletedValue); - public static VectorStoreFileStatusFilter Failed { get; } = new VectorStoreFileStatusFilter(FailedValue); - public static VectorStoreFileStatusFilter Cancelled { get; } = new VectorStoreFileStatusFilter(CancelledValue); - public static bool operator ==(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => left.Equals(right); - public static bool operator !=(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => !left.Equals(right); - public static implicit operator VectorStoreFileStatusFilter(string value) => new VectorStoreFileStatusFilter(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileStatusFilter other && Equals(other); - public bool Equals(VectorStoreFileStatusFilter other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - public override string ToString() => _value; + _value = value ?? throw new ArgumentNullException(nameof(value)); } -} + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + + public static VectorStoreFileStatusFilter InProgress { get; } = new VectorStoreFileStatusFilter(InProgressValue); + public static VectorStoreFileStatusFilter Completed { get; } = new VectorStoreFileStatusFilter(CompletedValue); + public static VectorStoreFileStatusFilter Failed { get; } = new VectorStoreFileStatusFilter(FailedValue); + public static VectorStoreFileStatusFilter Cancelled { get; } = new VectorStoreFileStatusFilter(CancelledValue); + public static bool operator ==(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => left.Equals(right); + public static bool operator !=(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => !left.Equals(right); + public static implicit operator VectorStoreFileStatusFilter(string value) => new VectorStoreFileStatusFilter(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileStatusFilter other && Equals(other); + public bool Equals(VectorStoreFileStatusFilter other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + public override string ToString() => _value; +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs b/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs index 16e2ec49..4ba87b39 100644 --- a/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs +++ b/src/Generated/Models/VectorStoreModificationOptions.Serialization.cs @@ -8,194 +8,193 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreModificationOptions : IJsonModel { - public partial class VectorStoreModificationOptions : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") + throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + { + if (Name != null) { - throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support writing '{format}' format."); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("name") != true && Optional.IsDefined(Name)) + else { - if (Name != null) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - else - { - writer.WriteNull("name"); - } + writer.WriteNull("name"); } - if (SerializedAdditionalRawData?.ContainsKey("expires_after") != true && Optional.IsDefined(ExpirationPolicy)) + } + if (SerializedAdditionalRawData?.ContainsKey("expires_after") != true && Optional.IsDefined(ExpirationPolicy)) + { + if (ExpirationPolicy != null) { - if (ExpirationPolicy != null) - { - writer.WritePropertyName("expires_after"u8); - writer.WriteObjectValue(ExpirationPolicy, options); - } - else - { - writer.WriteNull("expires_after"); - } + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpirationPolicy, options); } - if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + else { - if (Metadata != null) - { - writer.WritePropertyName("metadata"u8); - writer.WriteStartObject(); - foreach (var item in Metadata) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - else + writer.WriteNull("expires_after"); + } + } + if (SerializedAdditionalRawData?.ContainsKey("metadata") != true && Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) { - writer.WriteNull("metadata"); + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); } + writer.WriteEndObject(); } - if (SerializedAdditionalRawData != null) + else { - foreach (var item in SerializedAdditionalRawData) + writer.WriteNull("metadata"); + } + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - VectorStoreModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreModificationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeVectorStoreModificationOptions(document.RootElement, options); + throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support reading '{format}' format."); } - internal static VectorStoreModificationOptions DeserializeVectorStoreModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreModificationOptions(document.RootElement, options); + } - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string name = default; - VectorStoreExpirationPolicy expiresAfter = default; - IDictionary metadata = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + internal static VectorStoreModificationOptions DeserializeVectorStoreModificationOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + VectorStoreExpirationPolicy expiresAfter = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) { - if (property.NameEquals("name"u8)) + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - name = null; - continue; - } - name = property.Value.GetString(); + name = null; continue; } - if (property.NameEquals("expires_after"u8)) + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - expiresAfter = null; - continue; - } - expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + expiresAfter = null; continue; } - if (property.NameEquals("metadata"u8)) + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - metadata = dictionary; continue; } - if (true) + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + dictionary.Add(property0.Name, property0.Value.GetString()); } + metadata = dictionary; + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new VectorStoreModificationOptions(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreModificationOptions(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } - VectorStoreModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeVectorStoreModificationOptions(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + VectorStoreModificationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static VectorStoreModificationOptions FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeVectorStoreModificationOptions(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreModificationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreModificationOptions)} does not support reading '{options.Format}' format."); } + } - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static VectorStoreModificationOptions FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreModificationOptions(document.RootElement); + } + + internal virtual BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreModificationOptions.cs b/src/Generated/Models/VectorStoreModificationOptions.cs index 8597db68..de0057dd 100644 --- a/src/Generated/Models/VectorStoreModificationOptions.cs +++ b/src/Generated/Models/VectorStoreModificationOptions.cs @@ -5,25 +5,24 @@ using System; using System.Collections.Generic; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +public partial class VectorStoreModificationOptions { - public partial class VectorStoreModificationOptions + internal IDictionary SerializedAdditionalRawData { get; set; } + public VectorStoreModificationOptions() { - internal IDictionary SerializedAdditionalRawData { get; set; } - public VectorStoreModificationOptions() - { - Metadata = new ChangeTrackingDictionary(); - } - - internal VectorStoreModificationOptions(string name, VectorStoreExpirationPolicy expirationPolicy, IDictionary metadata, IDictionary serializedAdditionalRawData) - { - Name = name; - ExpirationPolicy = expirationPolicy; - Metadata = metadata; - SerializedAdditionalRawData = serializedAdditionalRawData; - } + Metadata = new ChangeTrackingDictionary(); + } - public string Name { get; set; } - public IDictionary Metadata { get; set; } + internal VectorStoreModificationOptions(string name, VectorStoreExpirationPolicy expirationPolicy, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + Name = name; + ExpirationPolicy = expirationPolicy; + Metadata = metadata; + SerializedAdditionalRawData = serializedAdditionalRawData; } -} + + public string Name { get; set; } + public IDictionary Metadata { get; set; } +} \ No newline at end of file diff --git a/src/Generated/Models/VectorStoreStatus.Serialization.cs b/src/Generated/Models/VectorStoreStatus.Serialization.cs index c4417aef..8ba1e92e 100644 --- a/src/Generated/Models/VectorStoreStatus.Serialization.cs +++ b/src/Generated/Models/VectorStoreStatus.Serialization.cs @@ -4,24 +4,23 @@ using System; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +internal static partial class VectorStoreStatusExtensions { - internal static partial class VectorStoreStatusExtensions + public static string ToSerialString(this VectorStoreStatus value) => value switch { - public static string ToSerialString(this VectorStoreStatus value) => value switch - { - VectorStoreStatus.Expired => "expired", - VectorStoreStatus.InProgress => "in_progress", - VectorStoreStatus.Completed => "completed", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreStatus value.") - }; + VectorStoreStatus.Expired => "expired", + VectorStoreStatus.InProgress => "in_progress", + VectorStoreStatus.Completed => "completed", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreStatus value.") + }; - public static VectorStoreStatus ToVectorStoreStatus(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "expired")) return VectorStoreStatus.Expired; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "in_progress")) return VectorStoreStatus.InProgress; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "completed")) return VectorStoreStatus.Completed; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreStatus value."); - } + public static VectorStoreStatus ToVectorStoreStatus(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "expired")) return VectorStoreStatus.Expired; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "in_progress")) return VectorStoreStatus.InProgress; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "completed")) return VectorStoreStatus.Completed; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown VectorStoreStatus value."); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/WeightsAndBiasesIntegration.Serialization.cs b/src/Generated/Models/WeightsAndBiasesIntegration.Serialization.cs index dfdc93fe..67768306 100644 --- a/src/Generated/Models/WeightsAndBiasesIntegration.Serialization.cs +++ b/src/Generated/Models/WeightsAndBiasesIntegration.Serialization.cs @@ -8,137 +8,136 @@ using System.Collections.Generic; using System.Text.Json; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class WeightsAndBiasesIntegration : IJsonModel { - internal partial class WeightsAndBiasesIntegration : IJsonModel + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support writing '{format}' format."); - } + throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support writing '{format}' format."); + } - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("wandb") != true) - { - writer.WritePropertyName("wandb"u8); - writer.WriteObjectValue(Wandb, options); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) + writer.WriteStartObject(); + if (SerializedAdditionalRawData?.ContainsKey("wandb") != true) + { + writer.WritePropertyName("wandb"u8); + writer.WriteObjectValue(Wandb, options); + } + if (SerializedAdditionalRawData?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (SerializedAdditionalRawData != null) + { + foreach (var item in SerializedAdditionalRawData) { - foreach (var item in SerializedAdditionalRawData) + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); + continue; + } + writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); } +#endif } - writer.WriteEndObject(); } + writer.WriteEndObject(); + } - WeightsAndBiasesIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + WeightsAndBiasesIntegration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeWeightsAndBiasesIntegration(document.RootElement, options); + throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support reading '{format}' format."); } - internal static WeightsAndBiasesIntegration DeserializeWeightsAndBiasesIntegration(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeightsAndBiasesIntegration(document.RootElement, options); + } + + internal static WeightsAndBiasesIntegration DeserializeWeightsAndBiasesIntegration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalCreateFineTuningJobRequestWandbIntegrationWandb wandb = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("wandb"u8)) { - return null; + wandb = InternalCreateFineTuningJobRequestWandbIntegrationWandb.DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(property.Value, options); + continue; } - InternalCreateFineTuningJobRequestWandbIntegrationWandb wandb = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + if (property.NameEquals("type"u8)) { - if (property.NameEquals("wandb"u8)) - { - wandb = InternalCreateFineTuningJobRequestWandbIntegrationWandb.DeserializeInternalCreateFineTuningJobRequestWandbIntegrationWandb(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (true) - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } + type = property.Value.GetString(); + continue; } - serializedAdditionalRawData = rawDataDictionary; - return new WeightsAndBiasesIntegration(type, serializedAdditionalRawData, wandb); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) + if (true) { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support writing '{options.Format}' format."); + rawDataDictionary ??= new Dictionary(); + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } + serializedAdditionalRawData = rawDataDictionary; + return new WeightsAndBiasesIntegration(type, serializedAdditionalRawData, wandb); + } - WeightsAndBiasesIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeWeightsAndBiasesIntegration(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support reading '{options.Format}' format."); - } + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support writing '{options.Format}' format."); } + } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + WeightsAndBiasesIntegration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - internal static new WeightsAndBiasesIntegration FromResponse(PipelineResponse response) + switch (format) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeWeightsAndBiasesIntegration(document.RootElement); + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWeightsAndBiasesIntegration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeightsAndBiasesIntegration)} does not support reading '{options.Format}' format."); } + } - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + internal static new WeightsAndBiasesIntegration FromResponse(PipelineResponse response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeWeightsAndBiasesIntegration(document.RootElement); + } + + internal override BinaryContent ToBinaryContent() + { + return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); } -} +} \ No newline at end of file diff --git a/src/Generated/Models/WeightsAndBiasesIntegration.cs b/src/Generated/Models/WeightsAndBiasesIntegration.cs index 98fb23f8..2cab4e8c 100644 --- a/src/Generated/Models/WeightsAndBiasesIntegration.cs +++ b/src/Generated/Models/WeightsAndBiasesIntegration.cs @@ -5,27 +5,26 @@ using System; using System.Collections.Generic; -namespace OpenAI.FineTuning +namespace OpenAI.FineTuning; + +internal partial class WeightsAndBiasesIntegration : FineTuningIntegration { - internal partial class WeightsAndBiasesIntegration : FineTuningIntegration + public WeightsAndBiasesIntegration(InternalCreateFineTuningJobRequestWandbIntegrationWandb wandb) { - public WeightsAndBiasesIntegration(InternalCreateFineTuningJobRequestWandbIntegrationWandb wandb) - { - Argument.AssertNotNull(wandb, nameof(wandb)); - - Type = "wandb"; - Wandb = wandb; - } + Argument.AssertNotNull(wandb, nameof(wandb)); - internal WeightsAndBiasesIntegration(string type, IDictionary serializedAdditionalRawData, InternalCreateFineTuningJobRequestWandbIntegrationWandb wandb) : base(type, serializedAdditionalRawData) - { - Wandb = wandb; - } + Type = "wandb"; + Wandb = wandb; + } - internal WeightsAndBiasesIntegration() - { - } + internal WeightsAndBiasesIntegration(string type, IDictionary serializedAdditionalRawData, InternalCreateFineTuningJobRequestWandbIntegrationWandb wandb) : base(type, serializedAdditionalRawData) + { + Wandb = wandb; + } - public InternalCreateFineTuningJobRequestWandbIntegrationWandb Wandb { get; } + internal WeightsAndBiasesIntegration() + { } -} + + public InternalCreateFineTuningJobRequestWandbIntegrationWandb Wandb { get; } +} \ No newline at end of file diff --git a/src/Generated/ModerationClient.cs b/src/Generated/ModerationClient.cs index 9eac7994..711a8924 100644 --- a/src/Generated/ModerationClient.cs +++ b/src/Generated/ModerationClient.cs @@ -5,43 +5,41 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.Moderations +namespace OpenAI.Moderations; + +// Data plane generated sub-client. +public partial class ModerationClient { - // Data plane generated sub-client. - public partial class ModerationClient + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; + + public virtual ClientPipeline Pipeline => _pipeline; + + protected ModerationClient() { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - - public virtual ClientPipeline Pipeline => _pipeline; - - protected ModerationClient() - { - } - - internal PipelineMessage CreateCreateModerationRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/moderations", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); } -} + + internal PipelineMessage CreateCreateModerationRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/moderations", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Generated/OpenAIClient.cs b/src/Generated/OpenAIClient.cs index 6b71023a..72545f07 100644 --- a/src/Generated/OpenAIClient.cs +++ b/src/Generated/OpenAIClient.cs @@ -5,35 +5,21 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading; -using OpenAI.Assistants; -using OpenAI.Audio; -using OpenAI.Batch; -using OpenAI.Chat; -using OpenAI.Embeddings; -using OpenAI.Files; -using OpenAI.FineTuning; -using OpenAI.Images; -using OpenAI.LegacyCompletions; -using OpenAI.Models; -using OpenAI.Moderations; -using OpenAI.VectorStores; -namespace OpenAI +namespace OpenAI; + +// Data plane generated client. +public partial class OpenAIClient { - // Data plane generated client. - public partial class OpenAIClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - public virtual ClientPipeline Pipeline => _pipeline; + public virtual ClientPipeline Pipeline => _pipeline; - protected OpenAIClient() - { - } + protected OpenAIClient() + { } -} +} \ No newline at end of file diff --git a/src/Generated/OpenAIClientOptions.cs b/src/Generated/OpenAIClientOptions.cs index fd56113e..904f5e7a 100644 --- a/src/Generated/OpenAIClientOptions.cs +++ b/src/Generated/OpenAIClientOptions.cs @@ -4,9 +4,8 @@ using System.ClientModel.Primitives; -namespace OpenAI +namespace OpenAI; + +public partial class OpenAIClientOptions : ClientPipelineOptions { - public partial class OpenAIClientOptions : ClientPipelineOptions - { - } -} +} \ No newline at end of file diff --git a/src/Generated/OpenAIModelFactory.cs b/src/Generated/OpenAIModelFactory.cs index 68a9674f..a12f6173 100644 --- a/src/Generated/OpenAIModelFactory.cs +++ b/src/Generated/OpenAIModelFactory.cs @@ -13,186 +13,185 @@ using OpenAI.Moderations; using OpenAI.VectorStores; -namespace OpenAI +namespace OpenAI; + +internal static partial class OpenAIModelFactory { - internal static partial class OpenAIModelFactory - { - public static VectorStoreFileCounts VectorStoreFileCounts(int inProgress = default, int completed = default, int failed = default, int cancelled = default, int total = default) - { - return new VectorStoreFileCounts( - inProgress, - completed, - failed, - cancelled, - total, - serializedAdditionalRawData: null); - } - - public static VectorStoreFileAssociationError VectorStoreFileAssociationError(VectorStoreFileAssociationErrorCode code = default, string message = null) - { - return new VectorStoreFileAssociationError(code, message, serializedAdditionalRawData: null); - } - - public static RunError RunError(RunErrorCode code = default, string message = null) - { - return new RunError(code, message, serializedAdditionalRawData: null); - } - - public static RunIncompleteDetails RunIncompleteDetails(RunIncompleteReason? reason = null) - { - return new RunIncompleteDetails(reason, serializedAdditionalRawData: null); - } - - public static RunTokenUsage RunTokenUsage(int completionTokens = default, int promptTokens = default, int totalTokens = default) - { - return new RunTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); - } - - public static RunStepError RunStepError(RunStepErrorCode code = default, string message = null) - { - return new RunStepError(code, message, serializedAdditionalRawData: null); - } - - public static RunStepTokenUsage RunStepTokenUsage(int completionTokens = default, int promptTokens = default, int totalTokens = default) - { - return new RunStepTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); - } - - public static ModerationCollection ModerationCollection(string id = null, string model = null, IEnumerable results = null) - { - results ??= new List(); - - return new ModerationCollection(id, model, results?.ToList()); - } - - public static ModerationResult ModerationResult(bool flagged = default, ModerationCategories categories = null, ModerationCategoryScores categoryScores = null) - { - return new ModerationResult(flagged, categories, categoryScores, serializedAdditionalRawData: null); - } - - public static ModerationCategories ModerationCategories(bool hate = default, bool hateThreatening = default, bool harassment = default, bool harassmentThreatening = default, bool selfHarm = default, bool selfHarmIntent = default, bool selfHarmInstructions = default, bool sexual = default, bool sexualMinors = default, bool violence = default, bool violenceGraphic = default) - { - return new ModerationCategories( - hate, - hateThreatening, - harassment, - harassmentThreatening, - selfHarm, - selfHarmIntent, - selfHarmInstructions, - sexual, - sexualMinors, - violence, - violenceGraphic, - serializedAdditionalRawData: null); - } - - public static ModerationCategoryScores ModerationCategoryScores(float hate = default, float hateThreatening = default, float harassment = default, float harassmentThreatening = default, float selfHarm = default, float selfHarmIntent = default, float selfHarmInstructions = default, float sexual = default, float sexualMinors = default, float violence = default, float violenceGraphic = default) - { - return new ModerationCategoryScores( - hate, - hateThreatening, - harassment, - harassmentThreatening, - selfHarm, - selfHarmIntent, - selfHarmInstructions, - sexual, - sexualMinors, - violence, - violenceGraphic, - serializedAdditionalRawData: null); - } - - public static MessageFailureDetails MessageFailureDetails(MessageFailureReason reason = default) - { - return new MessageFailureDetails(reason, serializedAdditionalRawData: null); - } - - public static GeneratedImageCollection GeneratedImageCollection(DateTimeOffset created = default, IEnumerable data = null) - { - data ??= new List(); - - return new GeneratedImageCollection(created, data?.ToList()); - } - - public static GeneratedImage GeneratedImage(BinaryData imageBytes = null, Uri imageUri = null, string revisedPrompt = null) - { - return new GeneratedImage(imageBytes, imageUri, revisedPrompt, serializedAdditionalRawData: null); - } - - public static EmbeddingTokenUsage EmbeddingTokenUsage(int inputTokens = default, int totalTokens = default) - { - return new EmbeddingTokenUsage(inputTokens, totalTokens, serializedAdditionalRawData: null); - } - - public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = default, int inputTokenCount = default, int totalTokenCount = default, ChatOutputTokenUsageDetails outputTokenDetails = null) - { - return new ChatTokenUsage(outputTokenCount, inputTokenCount, totalTokenCount, outputTokenDetails, serializedAdditionalRawData: null); - } - - public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default) - { - return new ChatOutputTokenUsageDetails(reasoningTokenCount, serializedAdditionalRawData: null); - } - - public static ToolChatMessage ToolChatMessage(IEnumerable content = null, string toolCallId = null) - { - content ??= new List(); - - return new ToolChatMessage(ChatMessageRole.Tool, content?.ToList(), serializedAdditionalRawData: null, toolCallId); - } - - public static FunctionChatMessage FunctionChatMessage(IEnumerable content = null, string functionName = null) - { - content ??= new List(); - - return new FunctionChatMessage(ChatMessageRole.Function, content?.ToList(), serializedAdditionalRawData: null, functionName); - } - - public static ChatFunction ChatFunction(string functionDescription = null, string functionName = null, BinaryData functionParameters = null) - { - return new ChatFunction(functionDescription, functionName, functionParameters, serializedAdditionalRawData: null); - } - - public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = default, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null) - { - topLogProbabilities ??= new List(); - - return new ChatTokenLogProbabilityDetails(token, logProbability, utf8Bytes, topLogProbabilities?.ToList(), serializedAdditionalRawData: null); - } - - public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = default, ReadOnlyMemory? utf8Bytes = null) - { - return new ChatTokenTopLogProbabilityDetails(token, logProbability, utf8Bytes, serializedAdditionalRawData: null); - } - - public static TranscribedWord TranscribedWord(string word = null, TimeSpan startTime = default, TimeSpan endTime = default) - { - return new TranscribedWord(word, startTime, endTime, serializedAdditionalRawData: null); - } - - public static TranscribedSegment TranscribedSegment(int id = default, int seekOffset = default, TimeSpan startTime = default, TimeSpan endTime = default, string text = null, IEnumerable tokenIds = null, float temperature = default, float averageLogProbability = default, float compressionRatio = default, float noSpeechProbability = default) - { - tokenIds ??= new List(); - - return new TranscribedSegment( - id, - seekOffset, - startTime, - endTime, - text, - tokenIds?.ToList(), - temperature, - averageLogProbability, - compressionRatio, - noSpeechProbability, - serializedAdditionalRawData: null); - } - - public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionArgumentsUpdate = null, string functionName = null) - { - return new StreamingChatFunctionCallUpdate(functionArgumentsUpdate, functionName, serializedAdditionalRawData: null); - } - } -} + public static VectorStoreFileCounts VectorStoreFileCounts(int inProgress = default, int completed = default, int failed = default, int cancelled = default, int total = default) + { + return new VectorStoreFileCounts( + inProgress, + completed, + failed, + cancelled, + total, + serializedAdditionalRawData: null); + } + + public static VectorStoreFileAssociationError VectorStoreFileAssociationError(VectorStoreFileAssociationErrorCode code = default, string message = null) + { + return new VectorStoreFileAssociationError(code, message, serializedAdditionalRawData: null); + } + + public static RunError RunError(RunErrorCode code = default, string message = null) + { + return new RunError(code, message, serializedAdditionalRawData: null); + } + + public static RunIncompleteDetails RunIncompleteDetails(RunIncompleteReason? reason = null) + { + return new RunIncompleteDetails(reason, serializedAdditionalRawData: null); + } + + public static RunTokenUsage RunTokenUsage(int completionTokens = default, int promptTokens = default, int totalTokens = default) + { + return new RunTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); + } + + public static RunStepError RunStepError(RunStepErrorCode code = default, string message = null) + { + return new RunStepError(code, message, serializedAdditionalRawData: null); + } + + public static RunStepTokenUsage RunStepTokenUsage(int completionTokens = default, int promptTokens = default, int totalTokens = default) + { + return new RunStepTokenUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); + } + + public static ModerationCollection ModerationCollection(string id = null, string model = null, IEnumerable results = null) + { + results ??= new List(); + + return new ModerationCollection(id, model, results?.ToList()); + } + + public static ModerationResult ModerationResult(bool flagged = default, ModerationCategories categories = null, ModerationCategoryScores categoryScores = null) + { + return new ModerationResult(flagged, categories, categoryScores, serializedAdditionalRawData: null); + } + + public static ModerationCategories ModerationCategories(bool hate = default, bool hateThreatening = default, bool harassment = default, bool harassmentThreatening = default, bool selfHarm = default, bool selfHarmIntent = default, bool selfHarmInstructions = default, bool sexual = default, bool sexualMinors = default, bool violence = default, bool violenceGraphic = default) + { + return new ModerationCategories( + hate, + hateThreatening, + harassment, + harassmentThreatening, + selfHarm, + selfHarmIntent, + selfHarmInstructions, + sexual, + sexualMinors, + violence, + violenceGraphic, + serializedAdditionalRawData: null); + } + + public static ModerationCategoryScores ModerationCategoryScores(float hate = default, float hateThreatening = default, float harassment = default, float harassmentThreatening = default, float selfHarm = default, float selfHarmIntent = default, float selfHarmInstructions = default, float sexual = default, float sexualMinors = default, float violence = default, float violenceGraphic = default) + { + return new ModerationCategoryScores( + hate, + hateThreatening, + harassment, + harassmentThreatening, + selfHarm, + selfHarmIntent, + selfHarmInstructions, + sexual, + sexualMinors, + violence, + violenceGraphic, + serializedAdditionalRawData: null); + } + + public static MessageFailureDetails MessageFailureDetails(MessageFailureReason reason = default) + { + return new MessageFailureDetails(reason, serializedAdditionalRawData: null); + } + + public static GeneratedImageCollection GeneratedImageCollection(DateTimeOffset created = default, IEnumerable data = null) + { + data ??= new List(); + + return new GeneratedImageCollection(created, data?.ToList()); + } + + public static GeneratedImage GeneratedImage(BinaryData imageBytes = null, Uri imageUri = null, string revisedPrompt = null) + { + return new GeneratedImage(imageBytes, imageUri, revisedPrompt, serializedAdditionalRawData: null); + } + + public static EmbeddingTokenUsage EmbeddingTokenUsage(int inputTokens = default, int totalTokens = default) + { + return new EmbeddingTokenUsage(inputTokens, totalTokens, serializedAdditionalRawData: null); + } + + public static ChatTokenUsage ChatTokenUsage(int outputTokenCount = default, int inputTokenCount = default, int totalTokenCount = default, ChatOutputTokenUsageDetails outputTokenDetails = null) + { + return new ChatTokenUsage(outputTokenCount, inputTokenCount, totalTokenCount, outputTokenDetails, serializedAdditionalRawData: null); + } + + public static ChatOutputTokenUsageDetails ChatOutputTokenUsageDetails(int reasoningTokenCount = default) + { + return new ChatOutputTokenUsageDetails(reasoningTokenCount, serializedAdditionalRawData: null); + } + + public static ToolChatMessage ToolChatMessage(IEnumerable content = null, string toolCallId = null) + { + content ??= new List(); + + return new ToolChatMessage(ChatMessageRole.Tool, content?.ToList(), serializedAdditionalRawData: null, toolCallId); + } + + public static FunctionChatMessage FunctionChatMessage(IEnumerable content = null, string functionName = null) + { + content ??= new List(); + + return new FunctionChatMessage(ChatMessageRole.Function, content?.ToList(), serializedAdditionalRawData: null, functionName); + } + + public static ChatFunction ChatFunction(string functionDescription = null, string functionName = null, BinaryData functionParameters = null) + { + return new ChatFunction(functionDescription, functionName, functionParameters, serializedAdditionalRawData: null); + } + + public static ChatTokenLogProbabilityDetails ChatTokenLogProbabilityDetails(string token = null, float logProbability = default, ReadOnlyMemory? utf8Bytes = null, IEnumerable topLogProbabilities = null) + { + topLogProbabilities ??= new List(); + + return new ChatTokenLogProbabilityDetails(token, logProbability, utf8Bytes, topLogProbabilities?.ToList(), serializedAdditionalRawData: null); + } + + public static ChatTokenTopLogProbabilityDetails ChatTokenTopLogProbabilityDetails(string token = null, float logProbability = default, ReadOnlyMemory? utf8Bytes = null) + { + return new ChatTokenTopLogProbabilityDetails(token, logProbability, utf8Bytes, serializedAdditionalRawData: null); + } + + public static TranscribedWord TranscribedWord(string word = null, TimeSpan startTime = default, TimeSpan endTime = default) + { + return new TranscribedWord(word, startTime, endTime, serializedAdditionalRawData: null); + } + + public static TranscribedSegment TranscribedSegment(int id = default, int seekOffset = default, TimeSpan startTime = default, TimeSpan endTime = default, string text = null, IEnumerable tokenIds = null, float temperature = default, float averageLogProbability = default, float compressionRatio = default, float noSpeechProbability = default) + { + tokenIds ??= new List(); + + return new TranscribedSegment( + id, + seekOffset, + startTime, + endTime, + text, + tokenIds?.ToList(), + temperature, + averageLogProbability, + compressionRatio, + noSpeechProbability, + serializedAdditionalRawData: null); + } + + public static StreamingChatFunctionCallUpdate StreamingChatFunctionCallUpdate(string functionArgumentsUpdate = null, string functionName = null) + { + return new StreamingChatFunctionCallUpdate(functionArgumentsUpdate, functionName, serializedAdditionalRawData: null); + } +} \ No newline at end of file diff --git a/src/Generated/VectorStoreClient.cs b/src/Generated/VectorStoreClient.cs index 5e44c7ab..3d53d92f 100644 --- a/src/Generated/VectorStoreClient.cs +++ b/src/Generated/VectorStoreClient.cs @@ -5,311 +5,309 @@ using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading.Tasks; -namespace OpenAI.VectorStores +namespace OpenAI.VectorStores; + +// Data plane generated sub-client. +public partial class VectorStoreClient { - // Data plane generated sub-client. - public partial class VectorStoreClient - { - private const string AuthorizationHeader = "Authorization"; - private readonly ApiKeyCredential _keyCredential; - private const string AuthorizationApiKeyPrefix = "Bearer"; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; + private const string AuthorizationHeader = "Authorization"; + private readonly ApiKeyCredential _keyCredential; + private const string AuthorizationApiKeyPrefix = "Bearer"; + private readonly ClientPipeline _pipeline; + private readonly Uri _endpoint; - public virtual ClientPipeline Pipeline => _pipeline; + public virtual ClientPipeline Pipeline => _pipeline; - protected VectorStoreClient() + protected VectorStoreClient() + { + } + + internal PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores", false); + if (limit != null) { + uri.AppendQuery("limit", limit.Value, true); } - - internal PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) + if (order != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("order", order, true); } - - internal PipelineMessage CreateCreateVectorStoreRequest(BinaryContent content, RequestOptions options) + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestOptions options) + if (before != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("before", before, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } - internal PipelineMessage CreateModifyVectorStoreRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + internal PipelineMessage CreateCreateVectorStoreRequest(BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateModifyVectorStoreRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteVectorStoreRequest(string vectorStoreId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "DELETE"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files", false); + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } - - internal PipelineMessage CreateDeleteVectorStoreRequest(string vectorStoreId, RequestOptions options) + if (order != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("order", order, true); } - - internal PipelineMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - if (filter != null) - { - uri.AppendQuery("filter", filter, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + if (before != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("before", before, true); } - - internal PipelineMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) + if (filter != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("filter", filter, true); } + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "DELETE"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCreateVectorStoreFileBatchRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } - internal PipelineMessage CreateDeleteVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) + internal PipelineMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "POST"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/cancel", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetFilesInVectorStoreBatchesRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) + { + var message = _pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + var request = message.Request; + request.Method = "GET"; + var uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/files", false); + if (limit != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("limit", limit.Value, true); } - - internal PipelineMessage CreateCreateVectorStoreFileBatchRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + if (order != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; + uri.AppendQuery("order", order, true); } - - internal PipelineMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) + if (after != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("after", after, true); } - - internal PipelineMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) + if (before != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("before", before, true); } - - internal PipelineMessage CreateGetFilesInVectorStoreBatchesRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) + if (filter != null) { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/files", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - if (filter != null) - { - uri.AppendQuery("filter", filter, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + uri.AppendQuery("filter", filter, true); } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; } -} + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); +} \ No newline at end of file diff --git a/src/Utility/AppContextSwitchHelper.cs b/src/Utility/AppContextSwitchHelper.cs index 34d98529..08471713 100644 --- a/src/Utility/AppContextSwitchHelper.cs +++ b/src/Utility/AppContextSwitchHelper.cs @@ -7,16 +7,16 @@ internal static class AppContextSwitchHelper /// /// Determines if either an AppContext switch or its corresponding Environment Variable is set /// - /// Name of the AppContext switch. + /// Name of the AppContext switch. /// Name of the Environment variable. /// If the AppContext switch has been set, returns the value of the switch. /// If the AppContext switch has not been set, returns the value of the environment variable. /// False if neither is set. /// - public static bool GetConfigValue(string appContexSwitchName, string environmentVariableName) + public static bool GetConfigValue(string appContextSwitchName, string environmentVariableName) { // First check for the AppContext switch, giving it priority over the environment variable. - if (AppContext.TryGetSwitch(appContexSwitchName, out bool value)) + if (AppContext.TryGetSwitch(appContextSwitchName, out bool value)) { return value; } diff --git a/src/Utility/Generator/CodeGenClientAttribute.cs b/src/Utility/Generator/CodeGenClientAttribute.cs index e46edc05..59292da6 100644 --- a/src/Utility/Generator/CodeGenClientAttribute.cs +++ b/src/Utility/Generator/CodeGenClientAttribute.cs @@ -5,11 +5,7 @@ namespace OpenAI; [AttributeUsage(AttributeTargets.Class)] -internal sealed class CodeGenClientAttribute : CodeGenTypeAttribute +internal sealed class CodeGenClientAttribute(string originalName) : CodeGenTypeAttribute(originalName) { public Type? ParentClient { get; set; } - - public CodeGenClientAttribute(string originalName) : base(originalName) - { - } } \ No newline at end of file diff --git a/src/Utility/Generator/CodeGenSuppressAttribute.cs b/src/Utility/Generator/CodeGenSuppressAttribute.cs index 8852cbc8..f58ec471 100644 --- a/src/Utility/Generator/CodeGenSuppressAttribute.cs +++ b/src/Utility/Generator/CodeGenSuppressAttribute.cs @@ -3,14 +3,8 @@ namespace OpenAI; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple = true)] -internal sealed class CodeGenSuppressAttribute : Attribute +internal sealed class CodeGenSuppressAttribute(string member, params Type[] parameters) : Attribute { - public string Member { get; } - public Type[] Parameters { get; } - - public CodeGenSuppressAttribute(string member, params Type[] parameters) - { - Member = member; - Parameters = parameters; - } + public string Member { get; } = member; + public Type[] Parameters { get; } = parameters; } \ No newline at end of file diff --git a/src/Utility/Generator/CodeGenTypeAttribute.cs b/src/Utility/Generator/CodeGenTypeAttribute.cs index 65aee7af..15e8cb81 100644 --- a/src/Utility/Generator/CodeGenTypeAttribute.cs +++ b/src/Utility/Generator/CodeGenTypeAttribute.cs @@ -5,12 +5,7 @@ namespace OpenAI; [AttributeUsage(AttributeTargets.Class)] -internal class CodeGenTypeAttribute : Attribute +internal class CodeGenTypeAttribute(string? originalName) : Attribute { - public string? OriginalName { get; } - - public CodeGenTypeAttribute(string? originalName) - { - OriginalName = originalName; - } + public string? OriginalName { get; } = originalName; } \ No newline at end of file diff --git a/src/Utility/GenericActionPipelinePolicy.cs b/src/Utility/GenericActionPipelinePolicy.cs index 5b7212f8..b2f904bc 100644 --- a/src/Utility/GenericActionPipelinePolicy.cs +++ b/src/Utility/GenericActionPipelinePolicy.cs @@ -5,18 +5,11 @@ namespace OpenAI; -internal partial class GenericActionPipelinePolicy : PipelinePolicy +internal partial class GenericActionPipelinePolicy(Action processMessageAction) : PipelinePolicy { - private Action _processMessageAction; - - public GenericActionPipelinePolicy(Action processMessageAction) - { - _processMessageAction = processMessageAction; - } - public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) { - _processMessageAction(message); + processMessageAction(message); if (currentIndex < pipeline.Count - 1) { pipeline[currentIndex + 1].Process(message, pipeline, currentIndex + 1); @@ -25,7 +18,7 @@ public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) { - _processMessageAction(message); + processMessageAction(message); if (currentIndex < pipeline.Count - 1) { await pipeline[currentIndex + 1].ProcessAsync(message, pipeline, currentIndex + 1); diff --git a/src/Utility/MultipartFormDataBinaryContent.cs b/src/Utility/MultipartFormDataBinaryContent.cs index a1d04afd..578d042a 100644 --- a/src/Utility/MultipartFormDataBinaryContent.cs +++ b/src/Utility/MultipartFormDataBinaryContent.cs @@ -12,16 +12,11 @@ namespace OpenAI; internal class MultipartFormDataBinaryContent : BinaryContent { - private readonly MultipartFormDataContent _multipartContent; + private readonly MultipartFormDataContent _multipartContent = new(CreateBoundary()); private const int BoundaryLength = 70; private const string BoundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; - public MultipartFormDataBinaryContent() - { - _multipartContent = new MultipartFormDataContent(CreateBoundary()); - } - public string ContentType { get diff --git a/src/Utility/Polyfill/System.Diagnostics.CodeAnalysis.ExperimentalAttribute.cs b/src/Utility/Polyfill/System.Diagnostics.CodeAnalysis.ExperimentalAttribute.cs index 45eed223..f136c942 100644 --- a/src/Utility/Polyfill/System.Diagnostics.CodeAnalysis.ExperimentalAttribute.cs +++ b/src/Utility/Polyfill/System.Diagnostics.CodeAnalysis.ExperimentalAttribute.cs @@ -4,57 +4,57 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -namespace System.Diagnostics.CodeAnalysis +namespace System.Diagnostics.CodeAnalysis; + +/// +/// Indicates that an API is experimental and it may change in the future. +/// +/// +/// This attribute allows call sites to be flagged with a diagnostic that indicates that an experimental +/// feature is used. Authors can use this attribute to ship preview features in their assemblies. +/// +[AttributeUsage(AttributeTargets.Assembly | + AttributeTargets.Module | + AttributeTargets.Class | + AttributeTargets.Struct | + AttributeTargets.Enum | + AttributeTargets.Constructor | + AttributeTargets.Method | + AttributeTargets.Property | + AttributeTargets.Field | + AttributeTargets.Event | + AttributeTargets.Interface | + AttributeTargets.Delegate, Inherited = false)] +internal sealed class ExperimentalAttribute : Attribute { /// - /// Indicates that an API is experimental and it may change in the future. + /// Initializes a new instance of the class, specifying the ID that the compiler will use + /// when reporting a use of the API the attribute applies to. /// - /// - /// This attribute allows call sites to be flagged with a diagnostic that indicates that an experimental - /// feature is used. Authors can use this attribute to ship preview features in their assemblies. - /// - [AttributeUsage(AttributeTargets.Assembly | - AttributeTargets.Module | - AttributeTargets.Class | - AttributeTargets.Struct | - AttributeTargets.Enum | - AttributeTargets.Constructor | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Field | - AttributeTargets.Event | - AttributeTargets.Interface | - AttributeTargets.Delegate, Inherited = false)] - internal sealed class ExperimentalAttribute : Attribute + /// The ID that the compiler will use when reporting a use of the API the attribute applies to. + public ExperimentalAttribute(string diagnosticId) { - /// - /// Initializes a new instance of the class, specifying the ID that the compiler will use - /// when reporting a use of the API the attribute applies to. - /// - /// The ID that the compiler will use when reporting a use of the API the attribute applies to. - public ExperimentalAttribute(string diagnosticId) - { - DiagnosticId = diagnosticId; - } + DiagnosticId = diagnosticId; + } - /// - /// Gets the ID that the compiler will use when reporting a use of the API the attribute applies to. - /// - /// The unique diagnostic ID. - /// - /// The diagnostic ID is shown in build output for warnings and errors. - /// This property represents the unique ID that can be used to suppress the warnings or errors, if needed. - /// - public string DiagnosticId { get; } + /// + /// Gets the ID that the compiler will use when reporting a use of the API the attribute applies to. + /// + /// The unique diagnostic ID. + /// + /// The diagnostic ID is shown in build output for warnings and errors. + /// This property represents the unique ID that can be used to suppress the warnings or errors, if needed. + /// + public string DiagnosticId { get; } - /// - /// Gets or sets the URL for corresponding documentation. - /// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID. - /// - /// The format string that represents a URL to corresponding documentation. - /// An example format string is https://contoso.com/obsoletion-warnings/{0}. - public string? UrlFormat { get; set; } - } + /// + /// Gets or sets the URL for corresponding documentation. + /// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID. + /// + /// The format string that represents a URL to corresponding documentation. + /// An example format string is https://contoso.com/obsoletion-warnings/{0}. + public string? UrlFormat { get; set; } } + #endif // !NET8_0_OR_LATER \ No newline at end of file diff --git a/src/Utility/System.Net.ServerSentEvents.cs b/src/Utility/System.Net.ServerSentEvents.cs index ea0b4f81..56737bfb 100644 --- a/src/Utility/System.Net.ServerSentEvents.cs +++ b/src/Utility/System.Net.ServerSentEvents.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // This file contains a source copy of: @@ -24,600 +24,599 @@ using System.Threading.Tasks; using System.Threading; -namespace System.Net.ServerSentEvents +namespace System.Net.ServerSentEvents; + +/// Represents a server-sent event. +/// Specifies the type of data payload in the event. +internal readonly struct SseItem { - /// Represents a server-sent event. - /// Specifies the type of data payload in the event. - internal readonly struct SseItem + /// Initializes the server-sent event. + /// The event's payload. + /// The event's type. + public SseItem(T data, string eventType) { - /// Initializes the server-sent event. - /// The event's payload. - /// The event's type. - public SseItem(T data, string eventType) - { - Data = data; - EventType = eventType; - } + Data = data; + EventType = eventType; + } - /// Gets the event's payload. - public T Data { get; } + /// Gets the event's payload. + public T Data { get; } - /// Gets the event's type. - public string EventType { get; } - } + /// Gets the event's type. + public string EventType { get; } +} - /// Encapsulates a method for parsing the bytes payload of a server-sent event. - /// Specifies the type of the return value of the parser. - /// The event's type. - /// The event's payload bytes. - /// The parsed . - internal delegate T SseItemParser(string eventType, ReadOnlySpan data); +/// Encapsulates a method for parsing the bytes payload of a server-sent event. +/// Specifies the type of the return value of the parser. +/// The event's type. +/// The event's payload bytes. +/// The parsed . +internal delegate T SseItemParser(string eventType, ReadOnlySpan data); - /// Provides a parser for parsing server-sent events. - internal static class SseParser +/// Provides a parser for parsing server-sent events. +internal static class SseParser +{ + /// The default ("message") for an event that did not explicitly specify a type. + public const string EventTypeDefault = "message"; + + /// Creates a parser for parsing a of server-sent events into a sequence of values. + /// The stream containing the data to parse. + /// + /// The enumerable of strings, which may be enumerated synchronously or asynchronously. The strings + /// are decoded from the UTF8-encoded bytes of the payload of each event. + /// + /// is null. + /// + /// This overload has behavior equivalent to calling with a delegate + /// that decodes the data of each event using 's GetString method. + /// + public static SseParser Create(Stream sseStream) => + Create(sseStream, static (_, bytes) => Utf8GetString(bytes)); + + /// Creates a parser for parsing a of server-sent events into a sequence of values. + /// Specifies the type of data in each event. + /// The stream containing the data to parse. + /// The parser to use to transform each payload of bytes into a data element. + /// The enumerable, which may be enumerated synchronously or asynchronously. + /// is null. + /// is null. + public static SseParser Create(Stream sseStream, SseItemParser itemParser) => + new SseParser( + sseStream ?? throw new ArgumentNullException(nameof(sseStream)), + itemParser ?? throw new ArgumentNullException(nameof(itemParser))); + + /// Encoding.UTF8.GetString(bytes) + internal static string Utf8GetString(ReadOnlySpan bytes) { - /// The default ("message") for an event that did not explicitly specify a type. - public const string EventTypeDefault = "message"; - - /// Creates a parser for parsing a of server-sent events into a sequence of values. - /// The stream containing the data to parse. - /// - /// The enumerable of strings, which may be enumerated synchronously or asynchronously. The strings - /// are decoded from the UTF8-encoded bytes of the payload of each event. - /// - /// is null. - /// - /// This overload has behavior equivalent to calling with a delegate - /// that decodes the data of each event using 's GetString method. - /// - public static SseParser Create(Stream sseStream) => - Create(sseStream, static (_, bytes) => Utf8GetString(bytes)); - - /// Creates a parser for parsing a of server-sent events into a sequence of values. - /// Specifies the type of data in each event. - /// The stream containing the data to parse. - /// The parser to use to transform each payload of bytes into a data element. - /// The enumerable, which may be enumerated synchronously or asynchronously. - /// is null. - /// is null. - public static SseParser Create(Stream sseStream, SseItemParser itemParser) => - new SseParser( - sseStream ?? throw new ArgumentNullException(nameof(sseStream)), - itemParser ?? throw new ArgumentNullException(nameof(itemParser))); - - /// Encoding.UTF8.GetString(bytes) - internal static string Utf8GetString(ReadOnlySpan bytes) - { #if NET return Encoding.UTF8.GetString(bytes); #else - unsafe + unsafe + { + fixed (byte* ptr = bytes) { - fixed (byte* ptr = bytes) - { - return ptr is null ? - string.Empty : - Encoding.UTF8.GetString(ptr, bytes.Length); - } + return ptr is null ? + string.Empty : + Encoding.UTF8.GetString(ptr, bytes.Length); } -#endif } +#endif } +} - /// Provides a parser for server-sent events information. - /// Specifies the type of data parsed from an event. - internal sealed class SseParser - { - // For reference: - // Specification: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events - - /// Carriage Return. - private const byte CR = (byte)'\r'; - /// Line Feed. - private const byte LF = (byte)'\n'; - /// Carriage Return Line Feed. - private static ReadOnlySpan CRLF => "\r\n"u8; - - /// The default size of an ArrayPool buffer to rent. - /// Larger size used by default to minimize number of reads. Smaller size used in debug to stress growth/shifting logic. - private const int DefaultArrayPoolRentSize = +/// Provides a parser for server-sent events information. +/// Specifies the type of data parsed from an event. +internal sealed class SseParser +{ + // For reference: + // Specification: https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events + + /// Carriage Return. + private const byte CR = (byte)'\r'; + /// Line Feed. + private const byte LF = (byte)'\n'; + /// Carriage Return Line Feed. + private static ReadOnlySpan CRLF => "\r\n"u8; + + /// The default size of an ArrayPool buffer to rent. + /// Larger size used by default to minimize number of reads. Smaller size used in debug to stress growth/shifting logic. + private const int DefaultArrayPoolRentSize = #if DEBUG 16; #else - 1024; + 1024; #endif - /// The stream to be parsed. - private readonly Stream _stream; - /// The parser delegate used to transform bytes into a . - private readonly SseItemParser _itemParser; - - /// Indicates whether the enumerable has already been used for enumeration. - private int _used; - - /// Buffer, either empty or rented, containing the data being read from the stream while looking for the next line. - private byte[] _lineBuffer = []; - /// The starting offset of valid data in . - private int _lineOffset; - /// The length of valid data in , starting from . - private int _lineLength; - /// The index in where a newline ('\r', '\n', or "\r\n") was found. - private int _newlineIndex; - /// The index in of characters already checked for newlines. - /// - /// This is to avoid O(LineLength^2) behavior in the rare case where we have long lines that are built-up over multiple reads. - /// We want to avoid re-checking the same characters we've already checked over and over again. - /// - private int _lastSearchedForNewline; - /// Set when eof has been reached in the stream. - private bool _eof; - - /// Rented buffer containing buffered data for the next event. - private byte[]? _dataBuffer; - /// The length of valid data in , starting from index 0. - private int _dataLength; - /// Whether data has been appended to . - /// This can be different than != 0 if empty data was appended. - private bool _dataAppended; - - /// The event type for the next event. - private string _eventType = SseParser.EventTypeDefault; - - /// Initialize the enumerable. - /// The stream to parse. - /// The function to use to parse payload bytes into a . - internal SseParser(Stream stream, SseItemParser itemParser) - { - _stream = stream; - _itemParser = itemParser; - } + /// The stream to be parsed. + private readonly Stream _stream; + /// The parser delegate used to transform bytes into a . + private readonly SseItemParser _itemParser; + + /// Indicates whether the enumerable has already been used for enumeration. + private int _used; + + /// Buffer, either empty or rented, containing the data being read from the stream while looking for the next line. + private byte[] _lineBuffer = []; + /// The starting offset of valid data in . + private int _lineOffset; + /// The length of valid data in , starting from . + private int _lineLength; + /// The index in where a newline ('\r', '\n', or "\r\n") was found. + private int _newlineIndex; + /// The index in of characters already checked for newlines. + /// + /// This is to avoid O(LineLength^2) behavior in the rare case where we have long lines that are built-up over multiple reads. + /// We want to avoid re-checking the same characters we've already checked over and over again. + /// + private int _lastSearchedForNewline; + /// Set when eof has been reached in the stream. + private bool _eof; + + /// Rented buffer containing buffered data for the next event. + private byte[]? _dataBuffer; + /// The length of valid data in , starting from index 0. + private int _dataLength; + /// Whether data has been appended to . + /// This can be different than != 0 if empty data was appended. + private bool _dataAppended; + + /// The event type for the next event. + private string _eventType = SseParser.EventTypeDefault; + + /// Initialize the enumerable. + /// The stream to parse. + /// The function to use to parse payload bytes into a . + internal SseParser(Stream stream, SseItemParser itemParser) + { + _stream = stream; + _itemParser = itemParser; + } - /// Gets an enumerable of the server-sent events from this parser. - /// The parser has already been enumerated. Such an exception may propagate out of a call to . - public IEnumerable> Enumerate() + /// Gets an enumerable of the server-sent events from this parser. + /// The parser has already been enumerated. Such an exception may propagate out of a call to . + public IEnumerable> Enumerate() + { + // Validate that the parser is only used for one enumeration. + ThrowIfNotFirstEnumeration(); + + // Rent a line buffer. This will grow as needed. The line buffer is what's passed to the stream, + // so we want it to be large enough to reduce the number of reads we need to do when data is + // arriving quickly. (In debug, we use a smaller buffer to stress the growth and shifting logic.) + _lineBuffer = ArrayPool.Shared.Rent(DefaultArrayPoolRentSize); + try { - // Validate that the parser is only used for one enumeration. - ThrowIfNotFirstEnumeration(); - - // Rent a line buffer. This will grow as needed. The line buffer is what's passed to the stream, - // so we want it to be large enough to reduce the number of reads we need to do when data is - // arriving quickly. (In debug, we use a smaller buffer to stress the growth and shifting logic.) - _lineBuffer = ArrayPool.Shared.Rent(DefaultArrayPoolRentSize); - try - { - // Spec: "Event streams in this format must always be encoded as UTF-8". - // Skip a UTF8 BOM if it exists at the beginning of the stream. (The BOM is defined as optional in the SSE grammar.) - while (FillLineBuffer() != 0 && _lineLength < Utf8Bom.Length) ; - SkipBomIfPresent(); + // Spec: "Event streams in this format must always be encoded as UTF-8". + // Skip a UTF8 BOM if it exists at the beginning of the stream. (The BOM is defined as optional in the SSE grammar.) + while (FillLineBuffer() != 0 && _lineLength < Utf8Bom.Length) ; + SkipBomIfPresent(); - // Process all events in the stream. - while (true) + // Process all events in the stream. + while (true) + { + // See if there's a complete line in data already read from the stream. Lines are permitted to + // end with CR, LF, or CRLF. Look for all of them and if we find one, process the line. However, + // if we only find a CR and it's at the end of the read data, don't process it now, as we want + // to process it together with an LF that might immediately follow, rather than treating them + // as two separate characters, in which case we'd incorrectly process the CR as a line by itself. + GetNextSearchOffsetAndLength(out int searchOffset, out int searchLength); + _newlineIndex = _lineBuffer.AsSpan(searchOffset, searchLength).IndexOfAny(CR, LF); + if (_newlineIndex >= 0) { - // See if there's a complete line in data already read from the stream. Lines are permitted to - // end with CR, LF, or CRLF. Look for all of them and if we find one, process the line. However, - // if we only find a CR and it's at the end of the read data, don't process it now, as we want - // to process it together with an LF that might immediately follow, rather than treating them - // as two separate characters, in which case we'd incorrectly process the CR as a line by itself. - GetNextSearchOffsetAndLength(out int searchOffset, out int searchLength); - _newlineIndex = _lineBuffer.AsSpan(searchOffset, searchLength).IndexOfAny(CR, LF); - if (_newlineIndex >= 0) + _lastSearchedForNewline = -1; + _newlineIndex += searchOffset; + if (_lineBuffer[_newlineIndex] is LF || // the newline is LF + _newlineIndex - _lineOffset + 1 < _lineLength || // we must have CR and we have whatever comes after it + _eof) // if we get here, we know we have a CR at the end of the buffer, so it's definitely the whole newline if we've hit EOF { - _lastSearchedForNewline = -1; - _newlineIndex += searchOffset; - if (_lineBuffer[_newlineIndex] is LF || // the newline is LF - _newlineIndex - _lineOffset + 1 < _lineLength || // we must have CR and we have whatever comes after it - _eof) // if we get here, we know we have a CR at the end of the buffer, so it's definitely the whole newline if we've hit EOF + // Process the line. + if (ProcessLine(out SseItem sseItem, out int advance)) { - // Process the line. - if (ProcessLine(out SseItem sseItem, out int advance)) - { - yield return sseItem; - } - - // Move past the line. - _lineOffset += advance; - _lineLength -= advance; - continue; + yield return sseItem; } - } - else - { - // Record the last position searched for a newline. The next time we search, - // we'll search from here rather than from _lineOffset, in order to avoid searching - // the same characters again. - _lastSearchedForNewline = _lineOffset + _lineLength; - } - // We've processed everything in the buffer we currently can, so if we've already read EOF, we're done. - if (_eof) - { - // Spec: "Once the end of the file is reached, any pending data must be discarded. (If the file ends in the middle of an - // event, before the final empty line, the incomplete event is not dispatched.)" - break; + // Move past the line. + _lineOffset += advance; + _lineLength -= advance; + continue; } + } + else + { + // Record the last position searched for a newline. The next time we search, + // we'll search from here rather than from _lineOffset, in order to avoid searching + // the same characters again. + _lastSearchedForNewline = _lineOffset + _lineLength; + } - // Read more data into the buffer. - FillLineBuffer(); + // We've processed everything in the buffer we currently can, so if we've already read EOF, we're done. + if (_eof) + { + // Spec: "Once the end of the file is reached, any pending data must be discarded. (If the file ends in the middle of an + // event, before the final empty line, the incomplete event is not dispatched.)" + break; } + + // Read more data into the buffer. + FillLineBuffer(); } - finally + } + finally + { + ArrayPool.Shared.Return(_lineBuffer); + if (_dataBuffer is not null) { - ArrayPool.Shared.Return(_lineBuffer); - if (_dataBuffer is not null) - { - ArrayPool.Shared.Return(_dataBuffer); - } + ArrayPool.Shared.Return(_dataBuffer); } } + } - /// Gets an asynchronous enumerable of the server-sent events from this parser. - /// The cancellation token to use to cancel the enumeration. - /// The parser has already been enumerated. Such an exception may propagate out of a call to . - /// The enumeration was canceled. Such an exception may propagate out of a call to . - public async IAsyncEnumerable> EnumerateAsync([EnumeratorCancellation] CancellationToken cancellationToken = default) + /// Gets an asynchronous enumerable of the server-sent events from this parser. + /// The cancellation token to use to cancel the enumeration. + /// The parser has already been enumerated. Such an exception may propagate out of a call to . + /// The enumeration was canceled. Such an exception may propagate out of a call to . + public async IAsyncEnumerable> EnumerateAsync([EnumeratorCancellation] CancellationToken cancellationToken = default) + { + // Validate that the parser is only used for one enumeration. + ThrowIfNotFirstEnumeration(); + + // Rent a line buffer. This will grow as needed. The line buffer is what's passed to the stream, + // so we want it to be large enough to reduce the number of reads we need to do when data is + // arriving quickly. (In debug, we use a smaller buffer to stress the growth and shifting logic.) + _lineBuffer = ArrayPool.Shared.Rent(DefaultArrayPoolRentSize); + try { - // Validate that the parser is only used for one enumeration. - ThrowIfNotFirstEnumeration(); - - // Rent a line buffer. This will grow as needed. The line buffer is what's passed to the stream, - // so we want it to be large enough to reduce the number of reads we need to do when data is - // arriving quickly. (In debug, we use a smaller buffer to stress the growth and shifting logic.) - _lineBuffer = ArrayPool.Shared.Rent(DefaultArrayPoolRentSize); - try - { - // Spec: "Event streams in this format must always be encoded as UTF-8". - // Skip a UTF8 BOM if it exists at the beginning of the stream. (The BOM is defined as optional in the SSE grammar.) - while (await FillLineBufferAsync(cancellationToken).ConfigureAwait(false) != 0 && _lineLength < Utf8Bom.Length) ; - SkipBomIfPresent(); + // Spec: "Event streams in this format must always be encoded as UTF-8". + // Skip a UTF8 BOM if it exists at the beginning of the stream. (The BOM is defined as optional in the SSE grammar.) + while (await FillLineBufferAsync(cancellationToken).ConfigureAwait(false) != 0 && _lineLength < Utf8Bom.Length) ; + SkipBomIfPresent(); - // Process all events in the stream. - while (true) + // Process all events in the stream. + while (true) + { + // See if there's a complete line in data already read from the stream. Lines are permitted to + // end with CR, LF, or CRLF. Look for all of them and if we find one, process the line. However, + // if we only find a CR and it's at the end of the read data, don't process it now, as we want + // to process it together with an LF that might immediately follow, rather than treating them + // as two separate characters, in which case we'd incorrectly process the CR as a line by itself. + GetNextSearchOffsetAndLength(out int searchOffset, out int searchLength); + _newlineIndex = _lineBuffer.AsSpan(searchOffset, searchLength).IndexOfAny(CR, LF); + if (_newlineIndex >= 0) { - // See if there's a complete line in data already read from the stream. Lines are permitted to - // end with CR, LF, or CRLF. Look for all of them and if we find one, process the line. However, - // if we only find a CR and it's at the end of the read data, don't process it now, as we want - // to process it together with an LF that might immediately follow, rather than treating them - // as two separate characters, in which case we'd incorrectly process the CR as a line by itself. - GetNextSearchOffsetAndLength(out int searchOffset, out int searchLength); - _newlineIndex = _lineBuffer.AsSpan(searchOffset, searchLength).IndexOfAny(CR, LF); - if (_newlineIndex >= 0) + _lastSearchedForNewline = -1; + _newlineIndex += searchOffset; + if (_lineBuffer[_newlineIndex] is LF || // newline is LF + _newlineIndex - _lineOffset + 1 < _lineLength || // newline is CR, and we have whatever comes after it + _eof) // if we get here, we know we have a CR at the end of the buffer, so it's definitely the whole newline if we've hit EOF { - _lastSearchedForNewline = -1; - _newlineIndex += searchOffset; - if (_lineBuffer[_newlineIndex] is LF || // newline is LF - _newlineIndex - _lineOffset + 1 < _lineLength || // newline is CR, and we have whatever comes after it - _eof) // if we get here, we know we have a CR at the end of the buffer, so it's definitely the whole newline if we've hit EOF + // Process the line. + if (ProcessLine(out SseItem sseItem, out int advance)) { - // Process the line. - if (ProcessLine(out SseItem sseItem, out int advance)) - { - yield return sseItem; - } - - // Move past the line. - _lineOffset += advance; - _lineLength -= advance; - continue; + yield return sseItem; } - } - else - { - // Record the last position searched for a newline. The next time we search, - // we'll search from here rather than from _lineOffset, in order to avoid searching - // the same characters again. - _lastSearchedForNewline = searchOffset + searchLength; - } - // We've processed everything in the buffer we currently can, so if we've already read EOF, we're done. - if (_eof) - { - // Spec: "Once the end of the file is reached, any pending data must be discarded. (If the file ends in the middle of an - // event, before the final empty line, the incomplete event is not dispatched.)" - break; + // Move past the line. + _lineOffset += advance; + _lineLength -= advance; + continue; } - - // Read more data into the buffer. - await FillLineBufferAsync(cancellationToken).ConfigureAwait(false); } - } - finally - { - ArrayPool.Shared.Return(_lineBuffer); - if (_dataBuffer is not null) + else { - ArrayPool.Shared.Return(_dataBuffer); + // Record the last position searched for a newline. The next time we search, + // we'll search from here rather than from _lineOffset, in order to avoid searching + // the same characters again. + _lastSearchedForNewline = searchOffset + searchLength; } + + // We've processed everything in the buffer we currently can, so if we've already read EOF, we're done. + if (_eof) + { + // Spec: "Once the end of the file is reached, any pending data must be discarded. (If the file ends in the middle of an + // event, before the final empty line, the incomplete event is not dispatched.)" + break; + } + + // Read more data into the buffer. + await FillLineBufferAsync(cancellationToken).ConfigureAwait(false); } } - - /// Gets the next index and length with which to perform a newline search. - private void GetNextSearchOffsetAndLength(out int searchOffset, out int searchLength) + finally { - if (_lastSearchedForNewline > _lineOffset) + ArrayPool.Shared.Return(_lineBuffer); + if (_dataBuffer is not null) { - searchOffset = _lastSearchedForNewline; - searchLength = _lineLength - (_lastSearchedForNewline - _lineOffset); + ArrayPool.Shared.Return(_dataBuffer); } - else - { - searchOffset = _lineOffset; - searchLength = _lineLength; - } - - Debug.Assert(searchOffset >= _lineOffset, $"{searchOffset}, {_lineLength}"); - Debug.Assert(searchOffset <= _lineOffset + _lineLength, $"{searchOffset}, {_lineOffset}, {_lineLength}"); - Debug.Assert(searchOffset <= _lineBuffer.Length, $"{searchOffset}, {_lineBuffer.Length}"); - - Debug.Assert(searchLength >= 0, $"{searchLength}"); - Debug.Assert(searchLength <= _lineLength, $"{searchLength}, {_lineLength}"); } + } - private int GetNewLineLength() + /// Gets the next index and length with which to perform a newline search. + private void GetNextSearchOffsetAndLength(out int searchOffset, out int searchLength) + { + if (_lastSearchedForNewline > _lineOffset) { - Debug.Assert(_newlineIndex - _lineOffset < _lineLength, "Expected to be positioned at a non-empty newline"); - return _lineBuffer.AsSpan(_newlineIndex, _lineLength - (_newlineIndex - _lineOffset)).StartsWith(CRLF) ? 2 : 1; + searchOffset = _lastSearchedForNewline; + searchLength = _lineLength - (_lastSearchedForNewline - _lineOffset); } + else + { + searchOffset = _lineOffset; + searchLength = _lineLength; + } + + Debug.Assert(searchOffset >= _lineOffset, $"{searchOffset}, {_lineLength}"); + Debug.Assert(searchOffset <= _lineOffset + _lineLength, $"{searchOffset}, {_lineOffset}, {_lineLength}"); + Debug.Assert(searchOffset <= _lineBuffer.Length, $"{searchOffset}, {_lineBuffer.Length}"); + + Debug.Assert(searchLength >= 0, $"{searchLength}"); + Debug.Assert(searchLength <= _lineLength, $"{searchLength}, {_lineLength}"); + } - /// - /// If there's no room remaining in the line buffer, either shifts the contents - /// left or grows the buffer in order to make room for the next read. - /// - private void ShiftOrGrowLineBufferIfNecessary() + private int GetNewLineLength() + { + Debug.Assert(_newlineIndex - _lineOffset < _lineLength, "Expected to be positioned at a non-empty newline"); + return _lineBuffer.AsSpan(_newlineIndex, _lineLength - (_newlineIndex - _lineOffset)).StartsWith(CRLF) ? 2 : 1; + } + + /// + /// If there's no room remaining in the line buffer, either shifts the contents + /// left or grows the buffer in order to make room for the next read. + /// + private void ShiftOrGrowLineBufferIfNecessary() + { + // If data we've read is butting up against the end of the buffer and + // it's not taking up the entire buffer, slide what's there down to + // the beginning, making room to read more data into the buffer (since + // there's no newline in the data that's there). Otherwise, if the whole + // buffer is full, grow the buffer to accommodate more data, since, again, + // what's there doesn't contain a newline and thus a line is longer than + // the current buffer accommodates. + if (_lineOffset + _lineLength == _lineBuffer.Length) { - // If data we've read is butting up against the end of the buffer and - // it's not taking up the entire buffer, slide what's there down to - // the beginning, making room to read more data into the buffer (since - // there's no newline in the data that's there). Otherwise, if the whole - // buffer is full, grow the buffer to accommodate more data, since, again, - // what's there doesn't contain a newline and thus a line is longer than - // the current buffer accommodates. - if (_lineOffset + _lineLength == _lineBuffer.Length) + if (_lineOffset != 0) { - if (_lineOffset != 0) - { - _lineBuffer.AsSpan(_lineOffset, _lineLength).CopyTo(_lineBuffer); - if (_lastSearchedForNewline >= 0) - { - _lastSearchedForNewline -= _lineOffset; - } - _lineOffset = 0; - } - else if (_lineLength == _lineBuffer.Length) + _lineBuffer.AsSpan(_lineOffset, _lineLength).CopyTo(_lineBuffer); + if (_lastSearchedForNewline >= 0) { - GrowBuffer(ref _lineBuffer!, _lineBuffer.Length * 2); + _lastSearchedForNewline -= _lineOffset; } + _lineOffset = 0; + } + else if (_lineLength == _lineBuffer.Length) + { + GrowBuffer(ref _lineBuffer!, _lineBuffer.Length * 2); } } + } + + /// Processes a complete line from the SSE stream. + /// The parsed item if the method returns true. + /// How many characters to advance in the line buffer. + /// true if an SSE item was successfully parsed; otherwise, false. + private bool ProcessLine(out SseItem sseItem, out int advance) + { + ReadOnlySpan line = _lineBuffer.AsSpan(_lineOffset, _newlineIndex - _lineOffset); - /// Processes a complete line from the SSE stream. - /// The parsed item if the method returns true. - /// How many characters to advance in the line buffer. - /// true if an SSE item was successfully parsed; otherwise, false. - private bool ProcessLine(out SseItem sseItem, out int advance) + // Spec: "If the line is empty (a blank line) Dispatch the event" + if (line.IsEmpty) { - ReadOnlySpan line = _lineBuffer.AsSpan(_lineOffset, _newlineIndex - _lineOffset); + advance = GetNewLineLength(); - // Spec: "If the line is empty (a blank line) Dispatch the event" - if (line.IsEmpty) + if (_dataAppended) { - advance = GetNewLineLength(); - - if (_dataAppended) - { - sseItem = new SseItem(_itemParser(_eventType, _dataBuffer.AsSpan(0, _dataLength)), _eventType); - _eventType = SseParser.EventTypeDefault; - _dataLength = 0; - _dataAppended = false; - return true; - } - - sseItem = default; - return false; + sseItem = new SseItem(_itemParser(_eventType, _dataBuffer.AsSpan(0, _dataLength)), _eventType); + _eventType = SseParser.EventTypeDefault; + _dataLength = 0; + _dataAppended = false; + return true; } - // Find the colon separating the field name and value. - int colonPos = line.IndexOf((byte)':'); - ReadOnlySpan fieldName; - ReadOnlySpan fieldValue; - if (colonPos >= 0) - { - // Spec: "Collect the characters on the line before the first U+003A COLON character (:), and let field be that string." - fieldName = line.Slice(0, colonPos); + sseItem = default; + return false; + } - // Spec: "Collect the characters on the line after the first U+003A COLON character (:), and let value be that string. - // If value starts with a U+0020 SPACE character, remove it from value." - fieldValue = line.Slice(colonPos + 1); - if (!fieldValue.IsEmpty && fieldValue[0] == (byte)' ') - { - fieldValue = fieldValue.Slice(1); - } - } - else - { - // Spec: "using the whole line as the field name, and the empty string as the field value." - fieldName = line; - fieldValue = []; - } + // Find the colon separating the field name and value. + int colonPos = line.IndexOf((byte)':'); + ReadOnlySpan fieldName; + ReadOnlySpan fieldValue; + if (colonPos >= 0) + { + // Spec: "Collect the characters on the line before the first U+003A COLON character (:), and let field be that string." + fieldName = line.Slice(0, colonPos); - if (fieldName.SequenceEqual("data"u8)) + // Spec: "Collect the characters on the line after the first U+003A COLON character (:), and let value be that string. + // If value starts with a U+0020 SPACE character, remove it from value." + fieldValue = line.Slice(colonPos + 1); + if (!fieldValue.IsEmpty && fieldValue[0] == (byte)' ') { - // Spec: "Append the field value to the data buffer, then append a single U+000A LINE FEED (LF) character to the data buffer." - // Spec: "If the data buffer's last character is a U+000A LINE FEED (LF) character, then remove the last character from the data buffer." - - // If there's nothing currently in the data buffer and we can easily detect that this line is immediately followed by - // an empty line, we can optimize it to just handle the data directly from the line buffer, rather than first copying - // into the data buffer and dispatching from there. - if (!_dataAppended) - { - int newlineLength = GetNewLineLength(); - ReadOnlySpan remainder = _lineBuffer.AsSpan(_newlineIndex + newlineLength, _lineLength - line.Length - newlineLength); - if (!remainder.IsEmpty && - (remainder[0] is LF || (remainder[0] is CR && remainder.Length > 1))) - { - advance = line.Length + newlineLength + (remainder.StartsWith(CRLF) ? 2 : 1); - sseItem = new SseItem(_itemParser(_eventType, fieldValue), _eventType); - _eventType = SseParser.EventTypeDefault; - return true; - } - } + fieldValue = fieldValue.Slice(1); + } + } + else + { + // Spec: "using the whole line as the field name, and the empty string as the field value." + fieldName = line; + fieldValue = []; + } - // We need to copy the data from the data buffer to the line buffer. Make sure there's enough room. - if (_dataBuffer is null || _dataLength + _lineLength + 1 > _dataBuffer.Length) - { - GrowBuffer(ref _dataBuffer, _dataLength + _lineLength + 1); - } + if (fieldName.SequenceEqual("data"u8)) + { + // Spec: "Append the field value to the data buffer, then append a single U+000A LINE FEED (LF) character to the data buffer." + // Spec: "If the data buffer's last character is a U+000A LINE FEED (LF) character, then remove the last character from the data buffer." - // Append a newline if there's already content in the buffer. - // Then copy the field value to the data buffer - if (_dataAppended) + // If there's nothing currently in the data buffer and we can easily detect that this line is immediately followed by + // an empty line, we can optimize it to just handle the data directly from the line buffer, rather than first copying + // into the data buffer and dispatching from there. + if (!_dataAppended) + { + int newlineLength = GetNewLineLength(); + ReadOnlySpan remainder = _lineBuffer.AsSpan(_newlineIndex + newlineLength, _lineLength - line.Length - newlineLength); + if (!remainder.IsEmpty && + (remainder[0] is LF || (remainder[0] is CR && remainder.Length > 1))) { - _dataBuffer![_dataLength++] = LF; + advance = line.Length + newlineLength + (remainder.StartsWith(CRLF) ? 2 : 1); + sseItem = new SseItem(_itemParser(_eventType, fieldValue), _eventType); + _eventType = SseParser.EventTypeDefault; + return true; } - fieldValue.CopyTo(_dataBuffer.AsSpan(_dataLength)); - _dataLength += fieldValue.Length; - _dataAppended = true; } - else if (fieldName.SequenceEqual("event"u8)) + + // We need to copy the data from the data buffer to the line buffer. Make sure there's enough room. + if (_dataBuffer is null || _dataLength + _lineLength + 1 > _dataBuffer.Length) { - // Spec: "Set the event type buffer to field value." - _eventType = SseParser.Utf8GetString(fieldValue); + GrowBuffer(ref _dataBuffer, _dataLength + _lineLength + 1); } - else if (fieldName.SequenceEqual("id"u8)) + + // Append a newline if there's already content in the buffer. + // Then copy the field value to the data buffer + if (_dataAppended) { - // Spec: "If the field value does not contain U+0000 NULL, then set the last event ID buffer to the field value. Otherwise, ignore the field." - if (fieldValue.IndexOf((byte)'\0') < 0) - { - // Note that fieldValue might be empty, in which case LastEventId will naturally be reset to the empty string. This is per spec. - LastEventId = SseParser.Utf8GetString(fieldValue); - } + _dataBuffer![_dataLength++] = LF; } - else if (fieldName.SequenceEqual("retry"u8)) + fieldValue.CopyTo(_dataBuffer.AsSpan(_dataLength)); + _dataLength += fieldValue.Length; + _dataAppended = true; + } + else if (fieldName.SequenceEqual("event"u8)) + { + // Spec: "Set the event type buffer to field value." + _eventType = SseParser.Utf8GetString(fieldValue); + } + else if (fieldName.SequenceEqual("id"u8)) + { + // Spec: "If the field value does not contain U+0000 NULL, then set the last event ID buffer to the field value. Otherwise, ignore the field." + if (fieldValue.IndexOf((byte)'\0') < 0) { - // Spec: "If the field value consists of only ASCII digits, then interpret the field value as an integer in base ten, - // and set the event stream's reconnection time to that integer. Otherwise, ignore the field." - if (long.TryParse( + // Note that fieldValue might be empty, in which case LastEventId will naturally be reset to the empty string. This is per spec. + LastEventId = SseParser.Utf8GetString(fieldValue); + } + } + else if (fieldName.SequenceEqual("retry"u8)) + { + // Spec: "If the field value consists of only ASCII digits, then interpret the field value as an integer in base ten, + // and set the event stream's reconnection time to that integer. Otherwise, ignore the field." + if (long.TryParse( #if NET7_0_OR_GREATER fieldValue, #else - SseParser.Utf8GetString(fieldValue), + SseParser.Utf8GetString(fieldValue), #endif - NumberStyles.None, CultureInfo.InvariantCulture, out long milliseconds)) - { - ReconnectionInterval = TimeSpan.FromMilliseconds(milliseconds); - } - } - else + NumberStyles.None, CultureInfo.InvariantCulture, out long milliseconds)) { - // We'll end up here if the line starts with a colon, producing an empty field name, or if the field name is otherwise unrecognized. - // Spec: "If the line starts with a U+003A COLON character (:) Ignore the line." - // Spec: "Otherwise, The field is ignored" + ReconnectionInterval = TimeSpan.FromMilliseconds(milliseconds); } - - advance = line.Length + GetNewLineLength(); - sseItem = default; - return false; } - - /// Gets the last event ID. - /// This value is updated any time a new last event ID is parsed. It is not reset between SSE items. - public string LastEventId { get; private set; } = string.Empty; // Spec: "must be initialized to the empty string" - - /// Gets the reconnection interval. - /// - /// If no retry event was received, this defaults to , and it will only - /// ever be in that situation. If a client wishes to retry, the server-sent - /// events specification states that the interval may then be decided by the client implementation and should be a - /// few seconds. - /// - public TimeSpan ReconnectionInterval { get; private set; } = Timeout.InfiniteTimeSpan; - - /// Transitions the object to a used state, throwing if it's already been used. - private void ThrowIfNotFirstEnumeration() + else { - if (Interlocked.Exchange(ref _used, 1) != 0) - { - throw new InvalidOperationException("The enumerable may be enumerated only once."); - } + // We'll end up here if the line starts with a colon, producing an empty field name, or if the field name is otherwise unrecognized. + // Spec: "If the line starts with a U+003A COLON character (:) Ignore the line." + // Spec: "Otherwise, The field is ignored" } - /// Reads data from the stream into the line buffer. - private int FillLineBuffer() + advance = line.Length + GetNewLineLength(); + sseItem = default; + return false; + } + + /// Gets the last event ID. + /// This value is updated any time a new last event ID is parsed. It is not reset between SSE items. + public string LastEventId { get; private set; } = string.Empty; // Spec: "must be initialized to the empty string" + + /// Gets the reconnection interval. + /// + /// If no retry event was received, this defaults to , and it will only + /// ever be in that situation. If a client wishes to retry, the server-sent + /// events specification states that the interval may then be decided by the client implementation and should be a + /// few seconds. + /// + public TimeSpan ReconnectionInterval { get; private set; } = Timeout.InfiniteTimeSpan; + + /// Transitions the object to a used state, throwing if it's already been used. + private void ThrowIfNotFirstEnumeration() + { + if (Interlocked.Exchange(ref _used, 1) != 0) { - ShiftOrGrowLineBufferIfNecessary(); + throw new InvalidOperationException("The enumerable may be enumerated only once."); + } + } - int offset = _lineOffset + _lineLength; - int bytesRead = _stream.Read( + /// Reads data from the stream into the line buffer. + private int FillLineBuffer() + { + ShiftOrGrowLineBufferIfNecessary(); + + int offset = _lineOffset + _lineLength; + int bytesRead = _stream.Read( #if NET _lineBuffer.AsSpan(offset)); #else - _lineBuffer, offset, _lineBuffer.Length - offset); + _lineBuffer, offset, _lineBuffer.Length - offset); #endif - if (bytesRead > 0) - { - _lineLength += bytesRead; - } - else - { - _eof = true; - bytesRead = 0; - } - - return bytesRead; + if (bytesRead > 0) + { + _lineLength += bytesRead; } - - /// Reads data asynchronously from the stream into the line buffer. - private async ValueTask FillLineBufferAsync(CancellationToken cancellationToken) + else { - ShiftOrGrowLineBufferIfNecessary(); + _eof = true; + bytesRead = 0; + } - int offset = _lineOffset + _lineLength; - int bytesRead = await + return bytesRead; + } + + /// Reads data asynchronously from the stream into the line buffer. + private async ValueTask FillLineBufferAsync(CancellationToken cancellationToken) + { + ShiftOrGrowLineBufferIfNecessary(); + + int offset = _lineOffset + _lineLength; + int bytesRead = await #if NET _stream.ReadAsync(_lineBuffer.AsMemory(offset), cancellationToken) #else - new ValueTask(_stream.ReadAsync(_lineBuffer, offset, _lineBuffer.Length - offset, cancellationToken)) + new ValueTask(_stream.ReadAsync(_lineBuffer, offset, _lineBuffer.Length - offset, cancellationToken)) #endif - .ConfigureAwait(false); - - if (bytesRead > 0) - { - _lineLength += bytesRead; - } - else - { - _eof = true; - bytesRead = 0; - } + .ConfigureAwait(false); - return bytesRead; + if (bytesRead > 0) + { + _lineLength += bytesRead; } + else + { + _eof = true; + bytesRead = 0; + } + + return bytesRead; + } - /// Gets the UTF8 BOM. - private static ReadOnlySpan Utf8Bom => [0xEF, 0xBB, 0xBF]; + /// Gets the UTF8 BOM. + private static ReadOnlySpan Utf8Bom => [0xEF, 0xBB, 0xBF]; - /// Called at the beginning of processing to skip over an optional UTF8 byte order mark. - private void SkipBomIfPresent() - { - Debug.Assert(_lineOffset == 0, $"Expected _lineOffset == 0, got {_lineOffset}"); + /// Called at the beginning of processing to skip over an optional UTF8 byte order mark. + private void SkipBomIfPresent() + { + Debug.Assert(_lineOffset == 0, $"Expected _lineOffset == 0, got {_lineOffset}"); - if (_lineBuffer.AsSpan(0, _lineLength).StartsWith(Utf8Bom)) - { - _lineOffset += 3; - _lineLength -= 3; - } + if (_lineBuffer.AsSpan(0, _lineLength).StartsWith(Utf8Bom)) + { + _lineOffset += 3; + _lineLength -= 3; } + } - /// Grows the buffer, returning the existing one to the ArrayPool and renting an ArrayPool replacement. - private static void GrowBuffer(ref byte[]? buffer, int minimumLength) + /// Grows the buffer, returning the existing one to the ArrayPool and renting an ArrayPool replacement. + private static void GrowBuffer(ref byte[]? buffer, int minimumLength) + { + byte[]? toReturn = buffer; + buffer = ArrayPool.Shared.Rent(Math.Max(minimumLength, DefaultArrayPoolRentSize)); + if (toReturn is not null) { - byte[]? toReturn = buffer; - buffer = ArrayPool.Shared.Rent(Math.Max(minimumLength, DefaultArrayPoolRentSize)); - if (toReturn is not null) - { - Array.Copy(toReturn, buffer, toReturn.Length); - ArrayPool.Shared.Return(toReturn); - } + Array.Copy(toReturn, buffer, toReturn.Length); + ArrayPool.Shared.Return(toReturn); } } } \ No newline at end of file diff --git a/src/Utility/Telemetry/OpenTelemetrySource.cs b/src/Utility/Telemetry/OpenTelemetrySource.cs index a0ac1fe4..b0eeff20 100644 --- a/src/Utility/Telemetry/OpenTelemetrySource.cs +++ b/src/Utility/Telemetry/OpenTelemetrySource.cs @@ -3,27 +3,16 @@ namespace OpenAI.Telemetry; -internal class OpenTelemetrySource +internal class OpenTelemetrySource(string model, Uri endpoint) { private const string ChatOperationName = "chat"; private readonly bool IsOTelEnabled = AppContextSwitchHelper .GetConfigValue("OpenAI.Experimental.EnableOpenTelemetry", "OPENAI_EXPERIMENTAL_ENABLE_OPEN_TELEMETRY"); - private readonly string _serverAddress; - private readonly int _serverPort; - private readonly string _model; - - public OpenTelemetrySource(string model, Uri endpoint) - { - _serverAddress = endpoint.Host; - _serverPort = endpoint.Port; - _model = model; - } - public OpenTelemetryScope StartChatScope(ChatCompletionOptions completionsOptions) { return IsOTelEnabled - ? OpenTelemetryScope.StartChat(_model, ChatOperationName, _serverAddress, _serverPort, completionsOptions) + ? OpenTelemetryScope.StartChat(model, ChatOperationName, endpoint.Host, endpoint.Port, completionsOptions) : null; } diff --git a/tests/Assistants/Assistants.VectorStoresTests.cs b/tests/Assistants/Assistants.VectorStoresTests.cs index eecc3b4d..38e5ec75 100644 --- a/tests/Assistants/Assistants.VectorStoresTests.cs +++ b/tests/Assistants/Assistants.VectorStoresTests.cs @@ -19,7 +19,7 @@ namespace OpenAI.Tests.VectorStores; [TestFixture(true)] [TestFixture(false)] [Category("Assistants")] -public class VectorStoresTests : SyncAsyncTestBase +public class VectorStoresTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private readonly List _jobsToCancel = []; private readonly List _associationsToRemove = []; @@ -30,11 +30,6 @@ public class VectorStoresTests : SyncAsyncTestBase private static VectorStoreClient GetTestClient() => GetTestClient(TestScenario.VectorStores); - public VectorStoresTests(bool isAsync) - : base(isAsync) - { - } - [Test] public async Task CanCreateGetAndDeleteVectorStores() { diff --git a/tests/Assistants/AssistantsTests.cs b/tests/Assistants/AssistantsTests.cs index b00c7bdf..c6e6a61a 100644 --- a/tests/Assistants/AssistantsTests.cs +++ b/tests/Assistants/AssistantsTests.cs @@ -21,7 +21,7 @@ namespace OpenAI.Tests.Assistants; [TestFixture(true)] [TestFixture(false)] [Category("Assistants")] -public class AssistantsTests : SyncAsyncTestBase +public class AssistantsTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private readonly List _assistantsToDelete = []; private readonly List _threadsToDelete = []; @@ -30,16 +30,10 @@ public class AssistantsTests : SyncAsyncTestBase private readonly List _vectorStoreIdsToDelete = []; private static readonly DateTimeOffset s_2024 = new(2024, 1, 1, 0, 0, 0, TimeSpan.Zero); - private static readonly string s_testAssistantName = $".NET SDK Test Assistant - Please Delete Me"; - private static readonly string s_cleanupMetadataKey = $"test_metadata_cleanup_eligible"; + private static readonly string s_cleanupMetadataKey = "test_metadata_cleanup_eligible"; private static AssistantClient GetTestClient() => GetTestClient(TestScenario.Assistants); - public AssistantsTests(bool isAsync) - : base(isAsync) - { - } - [OneTimeTearDown] protected void Cleanup() { diff --git a/tests/Audio/GenerateSpeechMockTests.cs b/tests/Audio/GenerateSpeechMockTests.cs index 37fb601f..0b1e37a2 100644 --- a/tests/Audio/GenerateSpeechMockTests.cs +++ b/tests/Audio/GenerateSpeechMockTests.cs @@ -12,15 +12,10 @@ namespace OpenAI.Tests.Audio; [Parallelizable(ParallelScope.All)] [Category("Audio")] [Category("Smoke")] -internal class GenerateSpeechMockTests : SyncAsyncTestBase +internal class GenerateSpeechMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public GenerateSpeechMockTests(bool isAsync) - : base(isAsync) - { - } - [Test] public void GenerateSpeechRespectsTheCancellationToken() { diff --git a/tests/Audio/GenerateSpeechTests.cs b/tests/Audio/GenerateSpeechTests.cs index b80e0809..c9b94731 100644 --- a/tests/Audio/GenerateSpeechTests.cs +++ b/tests/Audio/GenerateSpeechTests.cs @@ -12,12 +12,8 @@ namespace OpenAI.Tests.Audio; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Audio")] -public partial class GenerateSpeechTests : SyncAsyncTestBase +public partial class GenerateSpeechTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public GenerateSpeechTests(bool isAsync) : base(isAsync) - { - } - [Test] public async Task BasicTextToSpeechWorks() { diff --git a/tests/Audio/TranscriptionMockTests.cs b/tests/Audio/TranscriptionMockTests.cs index 6543c10d..6e3e4d19 100644 --- a/tests/Audio/TranscriptionMockTests.cs +++ b/tests/Audio/TranscriptionMockTests.cs @@ -15,15 +15,10 @@ namespace OpenAI.Tests.Audio; [Parallelizable(ParallelScope.All)] [Category("Audio")] [Category("Smoke")] -public partial class TranscriptionMockTests : SyncAsyncTestBase +public partial class TranscriptionMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public TranscriptionMockTests(bool isAsync) - : base(isAsync) - { - } - public enum AudioSourceKind { UsingStream, diff --git a/tests/Audio/TranscriptionTests.cs b/tests/Audio/TranscriptionTests.cs index 881ddac9..dcbe2d4c 100644 --- a/tests/Audio/TranscriptionTests.cs +++ b/tests/Audio/TranscriptionTests.cs @@ -15,12 +15,8 @@ namespace OpenAI.Tests.Audio; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Audio")] -public partial class TranscriptionTests : SyncAsyncTestBase +public partial class TranscriptionTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public TranscriptionTests(bool isAsync) : base(isAsync) - { - } - public enum AudioSourceKind { UsingStream, diff --git a/tests/Audio/TranslationMockTests.cs b/tests/Audio/TranslationMockTests.cs index e0d43014..c9072cbd 100644 --- a/tests/Audio/TranslationMockTests.cs +++ b/tests/Audio/TranslationMockTests.cs @@ -15,15 +15,10 @@ namespace OpenAI.Tests.Audio; [Parallelizable(ParallelScope.All)] [Category("Audio")] [Category("Smoke")] -public partial class TranslationMockTests : SyncAsyncTestBase +public partial class TranslationMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public TranslationMockTests(bool isAsync) - : base(isAsync) - { - } - public enum AudioSourceKind { UsingStream, diff --git a/tests/Audio/TranslationTests.cs b/tests/Audio/TranslationTests.cs index 7c6efb87..ba857c7d 100644 --- a/tests/Audio/TranslationTests.cs +++ b/tests/Audio/TranslationTests.cs @@ -3,7 +3,6 @@ using OpenAI.Tests.Utility; using System; using System.IO; -using System.Threading; using System.Threading.Tasks; using static OpenAI.Tests.TestHelpers; @@ -13,12 +12,8 @@ namespace OpenAI.Tests.Audio; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Audio")] -public partial class TranslationTests : SyncAsyncTestBase +public partial class TranslationTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public TranslationTests(bool isAsync) : base(isAsync) - { - } - public enum AudioSourceKind { UsingStream, diff --git a/tests/Batch/BatchTests.cs b/tests/Batch/BatchTests.cs index b6d28cc9..2bed683d 100644 --- a/tests/Batch/BatchTests.cs +++ b/tests/Batch/BatchTests.cs @@ -16,14 +16,10 @@ namespace OpenAI.Tests.Batch; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Batch")] -public class BatchTests : SyncAsyncTestBase +public class BatchTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static BatchClient GetTestClient() => GetTestClient(TestScenario.Batch); - public BatchTests(bool isAsync) : base(isAsync) - { - } - [Test] public void ListBatchesProtocol() { diff --git a/tests/Chat/ChatMockTests.cs b/tests/Chat/ChatMockTests.cs index 59e00b87..4f7e0141 100644 --- a/tests/Chat/ChatMockTests.cs +++ b/tests/Chat/ChatMockTests.cs @@ -15,14 +15,10 @@ namespace OpenAI.Tests.Chat; [Parallelizable(ParallelScope.All)] [Category("Chat")] [Category("Smoke")] -public class ChatMockTests : SyncAsyncTestBase +public class ChatMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public ChatMockTests(bool isAsync) : base(isAsync) - { - } - private static readonly List s_messages = new() { new UserChatMessage("Message content.") diff --git a/tests/Chat/ChatSmokeTests.cs b/tests/Chat/ChatSmokeTests.cs index c4824ace..a6565687 100644 --- a/tests/Chat/ChatSmokeTests.cs +++ b/tests/Chat/ChatSmokeTests.cs @@ -19,12 +19,8 @@ namespace OpenAI.Tests.Chat; [Parallelizable(ParallelScope.All)] [Category("Chat")] [Category("Smoke")] -public class ChatSmokeTests : SyncAsyncTestBase +public class ChatSmokeTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public ChatSmokeTests(bool isAsync) : base(isAsync) - { - } - [Test] public async Task SmokeTest() { diff --git a/tests/Chat/ChatTests.cs b/tests/Chat/ChatTests.cs index 614e028f..b976a87e 100644 --- a/tests/Chat/ChatTests.cs +++ b/tests/Chat/ChatTests.cs @@ -5,13 +5,11 @@ using OpenAI.Tests.Utility; using System; using System.ClientModel; -using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; -using System.Net.Http; using System.Text; using System.Text.Json; using System.Threading; @@ -25,12 +23,8 @@ namespace OpenAI.Tests.Chat; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Chat")] -public class ChatTests : SyncAsyncTestBase +public class ChatTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public ChatTests(bool isAsync) : base(isAsync) - { - } - [Test] public async Task HelloWorldChat() { diff --git a/tests/Chat/ChatToolTests.cs b/tests/Chat/ChatToolTests.cs index ed3448a0..536bf912 100644 --- a/tests/Chat/ChatToolTests.cs +++ b/tests/Chat/ChatToolTests.cs @@ -16,12 +16,8 @@ namespace OpenAI.Tests.Chat; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Chat")] -public class ChatToolTests : SyncAsyncTestBase +public class ChatToolTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public ChatToolTests(bool isAsync) : base(isAsync) - { - } - private const string GetNumberForWordToolName = "get_number_for_word"; private static ChatTool s_numberForWordTool = ChatTool.CreateFunctionTool( GetNumberForWordToolName, diff --git a/tests/Embeddings/EmbeddingsMockTests.cs b/tests/Embeddings/EmbeddingsMockTests.cs index 21994213..8638fe4b 100644 --- a/tests/Embeddings/EmbeddingsMockTests.cs +++ b/tests/Embeddings/EmbeddingsMockTests.cs @@ -14,15 +14,10 @@ namespace OpenAI.Tests.Embeddings; [Parallelizable(ParallelScope.All)] [Category("Embeddings")] [Category("Smoke")] -public class EmbeddingsMockTests : SyncAsyncTestBase +public class EmbeddingsMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public EmbeddingsMockTests(bool isAsync) - : base(isAsync) - { - } - [Test] public async Task GenerateEmbeddingDeserializesVector() { diff --git a/tests/Embeddings/EmbeddingsTests.cs b/tests/Embeddings/EmbeddingsTests.cs index 18a40650..c1b032f4 100644 --- a/tests/Embeddings/EmbeddingsTests.cs +++ b/tests/Embeddings/EmbeddingsTests.cs @@ -13,14 +13,10 @@ namespace OpenAI.Tests.Embeddings; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Embeddings")] -public class EmbeddingsTests : SyncAsyncTestBase +public class EmbeddingsTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static EmbeddingClient GetTestClient() => GetTestClient(TestScenario.Embeddings); - public EmbeddingsTests(bool isAsync) : base(isAsync) - { - } - public enum EmbeddingsInputKind { UsingStrings, diff --git a/tests/Files/Files.UploadsTests.cs b/tests/Files/Files.UploadsTests.cs index cd215190..65ed2a44 100644 --- a/tests/Files/Files.UploadsTests.cs +++ b/tests/Files/Files.UploadsTests.cs @@ -13,14 +13,10 @@ namespace OpenAI.Tests.Files; [TestFixture(false)] [Parallelizable(ParallelScope.Fixtures)] [Category("Uploads")] -public class UploadsTests : SyncAsyncTestBase +public class UploadsTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static FileClient GetTestClient() => GetTestClient(TestScenario.Files); - public UploadsTests(bool isAsync) : base(isAsync) - { - } - [Test] [TestCase(true)] [TestCase(false)] diff --git a/tests/Files/FilesMockTests.cs b/tests/Files/FilesMockTests.cs index ebb3fc33..d1abf404 100644 --- a/tests/Files/FilesMockTests.cs +++ b/tests/Files/FilesMockTests.cs @@ -15,15 +15,10 @@ namespace OpenAI.Tests.Files; [Parallelizable(ParallelScope.All)] [Category("Files")] [Category("Smoke")] -public class FilesMockTests : SyncAsyncTestBase +public class FilesMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public FilesMockTests(bool isAsync) - : base(isAsync) - { - } - public enum FileSourceKind { UsingStream, diff --git a/tests/Files/FilesTests.cs b/tests/Files/FilesTests.cs index 0ce6f460..c7dc69f6 100644 --- a/tests/Files/FilesTests.cs +++ b/tests/Files/FilesTests.cs @@ -14,14 +14,10 @@ namespace OpenAI.Tests.Files; [TestFixture(false)] [Parallelizable(ParallelScope.Fixtures)] [Category("Files")] -public class FilesTests : SyncAsyncTestBase +public class FilesTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static FileClient GetTestClient() => GetTestClient(TestScenario.Files); - public FilesTests(bool isAsync) : base(isAsync) - { - } - [Test] public async Task ListFiles() { diff --git a/tests/FineTuning/FineTuningTests.cs b/tests/FineTuning/FineTuningTests.cs index 678c9fa4..d5638dc9 100644 --- a/tests/FineTuning/FineTuningTests.cs +++ b/tests/FineTuning/FineTuningTests.cs @@ -14,13 +14,8 @@ namespace OpenAI.Tests.FineTuning; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("FineTuning")] -internal class FineTuningTests : SyncAsyncTestBase +internal class FineTuningTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public FineTuningTests(bool isAsync) - : base(isAsync) - { - } - [Test] public void CreateJobCanParseServiceError() { diff --git a/tests/Images/ImagesMockTests.cs b/tests/Images/ImagesMockTests.cs index f78677c5..ef191b7e 100644 --- a/tests/Images/ImagesMockTests.cs +++ b/tests/Images/ImagesMockTests.cs @@ -15,15 +15,10 @@ namespace OpenAI.Tests.Images; [Parallelizable(ParallelScope.All)] [Category("Images")] [Category("Smoke")] -public class ImagesMockTests : SyncAsyncTestBase +public class ImagesMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public ImagesMockTests(bool isAsync) - : base(isAsync) - { - } - public enum ImageSourceKind { UsingStream, diff --git a/tests/Images/ImagesTests.cs b/tests/Images/ImagesTests.cs index 3fe13179..7d97b137 100644 --- a/tests/Images/ImagesTests.cs +++ b/tests/Images/ImagesTests.cs @@ -15,14 +15,10 @@ namespace OpenAI.Tests.Images; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Images")] -public class ImagesTests : SyncAsyncTestBase +public class ImagesTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private const string CatPrompt = "A big cat with big round eyes and large cat ears, sitting in an empty room and looking at the camera."; - public ImagesTests(bool isAsync) : base(isAsync) - { - } - public enum ImageSourceKind { UsingStream, diff --git a/tests/Models/ModelsMockTests.cs b/tests/Models/ModelsMockTests.cs index 73b3d86e..f829cdb4 100644 --- a/tests/Models/ModelsMockTests.cs +++ b/tests/Models/ModelsMockTests.cs @@ -12,15 +12,10 @@ namespace OpenAI.Tests.Models; [Parallelizable(ParallelScope.All)] [Category("Models")] [Category("Smoke")] -public class ModelsMockTests : SyncAsyncTestBase +public class ModelsMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public ModelsMockTests(bool isAsync) - : base(isAsync) - { - } - [Test] public async Task GetModelDeserializesCreatedAt() { diff --git a/tests/Models/ModelsTests.cs b/tests/Models/ModelsTests.cs index 6966ca6e..4e2e03c1 100644 --- a/tests/Models/ModelsTests.cs +++ b/tests/Models/ModelsTests.cs @@ -13,12 +13,8 @@ namespace OpenAI.Tests.Models; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Models")] -public class ModelsTests : SyncAsyncTestBase +public class ModelsTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public ModelsTests(bool isAsync) : base(isAsync) - { - } - [Test] public async Task ListModels() { diff --git a/tests/Moderations/ModerationsMockTests.cs b/tests/Moderations/ModerationsMockTests.cs index ad3f7219..abbcce47 100644 --- a/tests/Moderations/ModerationsMockTests.cs +++ b/tests/Moderations/ModerationsMockTests.cs @@ -14,15 +14,10 @@ namespace OpenAI.Tests.Moderations; [Parallelizable(ParallelScope.All)] [Category("Moderations")] [Category("Smoke")] -public class ModerationsMockTests : SyncAsyncTestBase +public class ModerationsMockTests(bool isAsync) : SyncAsyncTestBase(isAsync) { private static readonly ApiKeyCredential s_fakeCredential = new ApiKeyCredential("key"); - public ModerationsMockTests(bool isAsync) - : base(isAsync) - { - } - [Test] public async Task ClassifyTextInputDeserializesHateCategory() { diff --git a/tests/Moderations/ModerationsTests.cs b/tests/Moderations/ModerationsTests.cs index 09d36bb8..4059463d 100644 --- a/tests/Moderations/ModerationsTests.cs +++ b/tests/Moderations/ModerationsTests.cs @@ -11,12 +11,8 @@ namespace OpenAI.Tests.Moderations; [TestFixture(false)] [Parallelizable(ParallelScope.All)] [Category("Moderations")] -public class ModerationsTests : SyncAsyncTestBase +public class ModerationsTests(bool isAsync) : SyncAsyncTestBase(isAsync) { - public ModerationsTests(bool isAsync) : base(isAsync) - { - } - [Test] public async Task ClassifySingleInput() { diff --git a/tests/Utility/MultipartFormDataBinaryContent.cs b/tests/Utility/MultipartFormDataBinaryContent.cs index 0baf09a5..10899897 100644 --- a/tests/Utility/MultipartFormDataBinaryContent.cs +++ b/tests/Utility/MultipartFormDataBinaryContent.cs @@ -10,16 +10,11 @@ namespace OpenAI.Tests; internal class MultipartFormDataBinaryContent : BinaryContent { - private readonly MultipartFormDataContent _multipartContent; + private readonly MultipartFormDataContent _multipartContent = new(CreateBoundary()); private const int BoundaryLength = 70; private const string BoundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; - public MultipartFormDataBinaryContent() - { - _multipartContent = new MultipartFormDataContent(CreateBoundary()); - } - public string ContentType => _multipartContent.Headers.ContentType.ToString(); public void Add(byte[] bytes, string name, string fileName, string contentType = null) diff --git a/tests/Utility/SyncAsyncTestBase.cs b/tests/Utility/SyncAsyncTestBase.cs index f647338c..74d76dad 100644 --- a/tests/Utility/SyncAsyncTestBase.cs +++ b/tests/Utility/SyncAsyncTestBase.cs @@ -2,14 +2,9 @@ namespace OpenAI.Tests.Utility { - public class SyncAsyncTestBase + public class SyncAsyncTestBase(bool isAsync) { - public bool IsAsync { get; } - - public SyncAsyncTestBase(bool isAsync) - { - IsAsync = isAsync; - } + public bool IsAsync { get; } = isAsync; protected void AssertAsyncOnly() { diff --git a/tests/Utility/TestPipelinePolicy.cs b/tests/Utility/TestPipelinePolicy.cs index 688c407e..96959007 100644 --- a/tests/Utility/TestPipelinePolicy.cs +++ b/tests/Utility/TestPipelinePolicy.cs @@ -1,23 +1,15 @@ using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Threading.Tasks; namespace OpenAI.Tests; -internal partial class TestPipelinePolicy : PipelinePolicy +internal partial class TestPipelinePolicy(Action processMessageAction) : PipelinePolicy { - private Action _processMessageAction; - - public TestPipelinePolicy(Action processMessageAction) - { - _processMessageAction = processMessageAction; - } - public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) { - _processMessageAction(message); + processMessageAction(message); if (currentIndex < pipeline.Count - 1) { pipeline[currentIndex + 1].Process(message, pipeline, currentIndex + 1); @@ -26,7 +18,7 @@ public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) { - _processMessageAction(message); + processMessageAction(message); if (currentIndex < pipeline.Count - 1) { await pipeline[currentIndex + 1].ProcessAsync(message, pipeline, currentIndex + 1);