openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.Serialization.cs
19lines · modecode
| 1 | using System.ClientModel.Primitives; |
| 2 | using System.Runtime.CompilerServices; |
| 3 | using System.Text.Json; |
| 4 | |
| 5 | namespace OpenAI.Chat; |
| 6 | |
| 7 | [CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))] |
| 8 | internal partial class InternalChatCompletionResponseMessage |
| 9 | { |
| 10 | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 11 | private void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) |
| 12 | => Content.WriteTo(writer, options); |
| 13 | |
| 14 | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 15 | private static void DeserializeContentValue(JsonProperty property, ref ChatMessageContent content, ModelReaderWriterOptions options = null) |
| 16 | { |
| 17 | content = ChatMessageContent.DeserializeChatMessageContent(property.Value, options); |
| 18 | } |
| 19 | } |
| 20 | |