openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Assistants/Internal/InternalAssistantResponseFormatPlainTextNoObject.Serialization.cs
36lines · modecode
| 1 | using System; |
| 2 | using System.ClientModel.Primitives; |
| 3 | using System.Text.Json; |
| 4 | |
| 5 | namespace OpenAI.Assistants; |
| 6 | |
| 7 | internal partial class InternalAssistantResponseFormatPlainTextNoObject : IJsonModel<InternalAssistantResponseFormatPlainTextNoObject> |
| 8 | { |
| 9 | internal static void SerializeInternalAssistantResponseFormatPlainTextNoObject(InternalAssistantResponseFormatPlainTextNoObject instance, Utf8JsonWriter writer, ModelReaderWriterOptions options = null) |
| 10 | { |
| 11 | writer.WriteStringValue(instance.Value); |
| 12 | } |
| 13 | |
| 14 | internal static InternalAssistantResponseFormatPlainTextNoObject DeserializeInternalAssistantResponseFormatPlainTextNoObject(JsonElement element, ModelReaderWriterOptions options = null) |
| 15 | { |
| 16 | if (element.ValueKind == JsonValueKind.String) |
| 17 | { |
| 18 | return new(element.GetString()); |
| 19 | } |
| 20 | return null; |
| 21 | } |
| 22 | |
| 23 | void IJsonModel<InternalAssistantResponseFormatPlainTextNoObject>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) |
| 24 | => CustomSerializationHelpers.SerializeInstance(this, SerializeInternalAssistantResponseFormatPlainTextNoObject, writer, options); |
| 25 | |
| 26 | InternalAssistantResponseFormatPlainTextNoObject IJsonModel<InternalAssistantResponseFormatPlainTextNoObject>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) |
| 27 | => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeInternalAssistantResponseFormatPlainTextNoObject, ref reader, options); |
| 28 | |
| 29 | BinaryData IPersistableModel<InternalAssistantResponseFormatPlainTextNoObject>.Write(ModelReaderWriterOptions options) |
| 30 | => CustomSerializationHelpers.SerializeInstance(this, options); |
| 31 | |
| 32 | InternalAssistantResponseFormatPlainTextNoObject IPersistableModel<InternalAssistantResponseFormatPlainTextNoObject>.Create(BinaryData data, ModelReaderWriterOptions options) |
| 33 | => CustomSerializationHelpers.DeserializeNewInstance(this, DeserializeInternalAssistantResponseFormatPlainTextNoObject, data, options); |
| 34 | |
| 35 | string IPersistableModel<InternalAssistantResponseFormatPlainTextNoObject>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; |
| 36 | } |
| 37 | |