openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/customize-openairesponsescontext-attribute

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

OpenAI/src/Custom/Chat/Internal/InternalChatCompletionResponseMessage.Serialization.cs

20lines · modecode

1using Microsoft.TypeSpec.Generator.Customizations;
2using System.ClientModel.Primitives;
3using System.Runtime.CompilerServices;
4using System.Text.Json;
5
6namespace OpenAI.Chat;
7
8[CodeGenSerialization(nameof(Content), SerializationValueHook = nameof(SerializeContentValue), DeserializationValueHook = nameof(DeserializeContentValue))]
9internal partial class InternalChatCompletionResponseMessage
10{
11 [MethodImpl(MethodImplOptions.AggressiveInlining)]
12 private void SerializeContentValue(Utf8JsonWriter writer, ModelReaderWriterOptions options)
13 => Content.WriteTo(writer, options);
14
15 [MethodImpl(MethodImplOptions.AggressiveInlining)]
16 private static void DeserializeContentValue(JsonProperty property, ref ChatMessageContent content, ModelReaderWriterOptions options = null)
17 {
18 content = ChatMessageContent.DeserializeChatMessageContent(property.Value, options);
19 }
20}