@@ -13,7 +13,7 @@ namespace OpenAI.Chat
1313{
1414 public partial class ChatCompletionMessageListDatum : IJsonModel < ChatCompletionMessageListDatum >
1515 {
16- internal ChatCompletionMessageListDatum ( ) : this ( null , null , null , null , null , default , null , null , null , default )
16+ internal ChatCompletionMessageListDatum ( ) : this ( null , null , null , null , default , null , null , null , null , default )
1717 {
1818 }
1919
@@ -49,29 +49,6 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
4949 {
5050 writer . WriteNull ( "content"u8 ) ;
5151 }
52- if ( Patch . Contains ( "$.content_parts"u8 ) )
53- {
54- if ( ! Patch . IsRemoved ( "$.content_parts"u8 ) )
55- {
56- writer . WritePropertyName ( "content_parts"u8 ) ;
57- writer . WriteRawValue ( Patch . GetJson ( "$.content_parts"u8 ) ) ;
58- }
59- }
60- else if ( Optional . IsCollectionDefined ( ContentParts ) )
61- {
62- writer . WritePropertyName ( "content_parts"u8 ) ;
63- writer . WriteStartArray ( ) ;
64- for ( int i = 0 ; i < ContentParts . Count ; i ++ )
65- {
66- if ( ContentParts [ i ] . Patch . IsRemoved ( "$"u8 ) )
67- {
68- continue ;
69- }
70- writer . WriteObjectValue ( ContentParts [ i ] , options ) ;
71- }
72- Patch . WriteTo ( writer , "$.content_parts"u8 ) ;
73- writer . WriteEndArray ( ) ;
74- }
7552 if ( Optional . IsDefined ( Refusal ) && ! Patch . Contains ( "$.refusal"u8 ) )
7653 {
7754 writer . WritePropertyName ( "refusal"u8 ) ;
@@ -142,6 +119,29 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit
142119 writer . WritePropertyName ( "audio"u8 ) ;
143120 writer . WriteObjectValue ( OutputAudio , options ) ;
144121 }
122+ if ( Patch . Contains ( "$.content_parts"u8 ) )
123+ {
124+ if ( ! Patch . IsRemoved ( "$.content_parts"u8 ) )
125+ {
126+ writer . WritePropertyName ( "content_parts"u8 ) ;
127+ writer . WriteRawValue ( Patch . GetJson ( "$.content_parts"u8 ) ) ;
128+ }
129+ }
130+ else if ( Optional . IsCollectionDefined ( ContentParts ) )
131+ {
132+ writer . WritePropertyName ( "content_parts"u8 ) ;
133+ writer . WriteStartArray ( ) ;
134+ for ( int i = 0 ; i < ContentParts . Count ; i ++ )
135+ {
136+ if ( ContentParts [ i ] . Patch . IsRemoved ( "$"u8 ) )
137+ {
138+ continue ;
139+ }
140+ writer . WriteObjectValue ( ContentParts [ i ] , options ) ;
141+ }
142+ Patch . WriteTo ( writer , "$.content_parts"u8 ) ;
143+ writer . WriteEndArray ( ) ;
144+ }
145145 if ( ! Patch . Contains ( "$.id"u8 ) )
146146 {
147147 writer . WritePropertyName ( "id"u8 ) ;
@@ -172,13 +172,13 @@ internal static ChatCompletionMessageListDatum DeserializeChatCompletionMessageL
172172 return null ;
173173 }
174174 string content = default ;
175- IList < ChatMessageContentPart > contentParts = default ;
176175 string refusal = default ;
177176 IReadOnlyList < ChatToolCall > toolCalls = default ;
178177 IReadOnlyList < ChatMessageAnnotation > annotations = default ;
179178 ChatMessageRole role = default ;
180179 InternalChatCompletionResponseMessageFunctionCall functionCall = default ;
181180 ChatOutputAudio outputAudio = default ;
181+ IList < ChatMessageContentPart > contentParts = default ;
182182 string id = default ;
183183#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
184184 JsonPatch patch = new JsonPatch ( data is null ? ReadOnlyMemory < byte > . Empty : data . ToMemory ( ) ) ;
@@ -195,20 +195,6 @@ internal static ChatCompletionMessageListDatum DeserializeChatCompletionMessageL
195195 content = prop . Value . GetString ( ) ;
196196 continue ;
197197 }
198- if ( prop . NameEquals ( "content_parts"u8 ) )
199- {
200- if ( prop . Value . ValueKind == JsonValueKind . Null )
201- {
202- continue ;
203- }
204- List < ChatMessageContentPart > array = new List < ChatMessageContentPart > ( ) ;
205- foreach ( var item in prop . Value . EnumerateArray ( ) )
206- {
207- array . Add ( ChatMessageContentPart . DeserializeChatMessageContentPart ( item , item . GetUtf8Bytes ( ) , options ) ) ;
208- }
209- contentParts = array ;
210- continue ;
211- }
212198 if ( prop . NameEquals ( "refusal"u8 ) )
213199 {
214200 if ( prop . Value . ValueKind == JsonValueKind . Null )
@@ -271,6 +257,20 @@ internal static ChatCompletionMessageListDatum DeserializeChatCompletionMessageL
271257 outputAudio = ChatOutputAudio . DeserializeChatOutputAudio ( prop . Value , prop . Value . GetUtf8Bytes ( ) , options ) ;
272258 continue ;
273259 }
260+ if ( prop . NameEquals ( "content_parts"u8 ) )
261+ {
262+ if ( prop . Value . ValueKind == JsonValueKind . Null )
263+ {
264+ continue ;
265+ }
266+ List < ChatMessageContentPart > array = new List < ChatMessageContentPart > ( ) ;
267+ foreach ( var item in prop . Value . EnumerateArray ( ) )
268+ {
269+ array . Add ( ChatMessageContentPart . DeserializeChatMessageContentPart ( item , item . GetUtf8Bytes ( ) , options ) ) ;
270+ }
271+ contentParts = array ;
272+ continue ;
273+ }
274274 if ( prop . NameEquals ( "id"u8 ) )
275275 {
276276 id = prop . Value . GetString ( ) ;
@@ -280,13 +280,13 @@ internal static ChatCompletionMessageListDatum DeserializeChatCompletionMessageL
280280 }
281281 return new ChatCompletionMessageListDatum (
282282 content ,
283- contentParts ?? new ChangeTrackingList < ChatMessageContentPart > ( ) ,
284283 refusal ,
285284 toolCalls ?? new ChangeTrackingList < ChatToolCall > ( ) ,
286285 annotations ?? new ChangeTrackingList < ChatMessageAnnotation > ( ) ,
287286 role ,
288287 functionCall ,
289288 outputAudio ,
289+ contentParts ?? new ChangeTrackingList < ChatMessageContentPart > ( ) ,
290290 id ,
291291 patch ) ;
292292 }
@@ -334,35 +334,35 @@ private bool PropagateGet(ReadOnlySpan<byte> jsonPath, out JsonPatch.EncodedValu
334334 {
335335 return FunctionCall . Patch . TryGetEncodedValue ( [ .. "$"u8 , .. local . Slice ( "function_call"u8 . Length ) ] , out value ) ;
336336 }
337- if ( local . StartsWith ( "content_parts "u8 ) )
337+ if ( local . StartsWith ( "tool_calls "u8 ) )
338338 {
339- int propertyLength = "content_parts "u8 . Length ;
339+ int propertyLength = "tool_calls "u8 . Length ;
340340 ReadOnlySpan < byte > currentSlice = local . Slice ( propertyLength ) ;
341341 if ( ! currentSlice . TryGetIndex ( out int index , out int bytesConsumed ) )
342342 {
343343 return false ;
344344 }
345- return ContentParts [ index ] . Patch . TryGetEncodedValue ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , out value ) ;
345+ return ToolCalls [ index ] . Patch . TryGetEncodedValue ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , out value ) ;
346346 }
347- if ( local . StartsWith ( "tool_calls "u8 ) )
347+ if ( local . StartsWith ( "annotations "u8 ) )
348348 {
349- int propertyLength = "tool_calls "u8 . Length ;
349+ int propertyLength = "annotations "u8 . Length ;
350350 ReadOnlySpan < byte > currentSlice = local . Slice ( propertyLength ) ;
351351 if ( ! currentSlice . TryGetIndex ( out int index , out int bytesConsumed ) )
352352 {
353353 return false ;
354354 }
355- return ToolCalls [ index ] . Patch . TryGetEncodedValue ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , out value ) ;
355+ return Annotations [ index ] . Patch . TryGetEncodedValue ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , out value ) ;
356356 }
357- if ( local . StartsWith ( "annotations "u8 ) )
357+ if ( local . StartsWith ( "content_parts "u8 ) )
358358 {
359- int propertyLength = "annotations "u8 . Length ;
359+ int propertyLength = "content_parts "u8 . Length ;
360360 ReadOnlySpan < byte > currentSlice = local . Slice ( propertyLength ) ;
361361 if ( ! currentSlice . TryGetIndex ( out int index , out int bytesConsumed ) )
362362 {
363363 return false ;
364364 }
365- return Annotations [ index ] . Patch . TryGetEncodedValue ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , out value ) ;
365+ return ContentParts [ index ] . Patch . TryGetEncodedValue ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , out value ) ;
366366 }
367367 return false ;
368368 }
@@ -378,37 +378,37 @@ private bool PropagateSet(ReadOnlySpan<byte> jsonPath, JsonPatch.EncodedValue va
378378 FunctionCall . Patch . Set ( [ .. "$"u8 , .. local . Slice ( "function_call"u8 . Length ) ] , value ) ;
379379 return true ;
380380 }
381- if ( local . StartsWith ( "content_parts "u8 ) )
381+ if ( local . StartsWith ( "tool_calls "u8 ) )
382382 {
383- int propertyLength = "content_parts "u8 . Length ;
383+ int propertyLength = "tool_calls "u8 . Length ;
384384 ReadOnlySpan < byte > currentSlice = local . Slice ( propertyLength ) ;
385385 if ( ! currentSlice . TryGetIndex ( out int index , out int bytesConsumed ) )
386386 {
387387 return false ;
388388 }
389- ContentParts [ index ] . Patch . Set ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , value ) ;
389+ ToolCalls [ index ] . Patch . Set ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , value ) ;
390390 return true ;
391391 }
392- if ( local . StartsWith ( "tool_calls "u8 ) )
392+ if ( local . StartsWith ( "annotations "u8 ) )
393393 {
394- int propertyLength = "tool_calls "u8 . Length ;
394+ int propertyLength = "annotations "u8 . Length ;
395395 ReadOnlySpan < byte > currentSlice = local . Slice ( propertyLength ) ;
396396 if ( ! currentSlice . TryGetIndex ( out int index , out int bytesConsumed ) )
397397 {
398398 return false ;
399399 }
400- ToolCalls [ index ] . Patch . Set ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , value ) ;
400+ Annotations [ index ] . Patch . Set ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , value ) ;
401401 return true ;
402402 }
403- if ( local . StartsWith ( "annotations "u8 ) )
403+ if ( local . StartsWith ( "content_parts "u8 ) )
404404 {
405- int propertyLength = "annotations "u8 . Length ;
405+ int propertyLength = "content_parts "u8 . Length ;
406406 ReadOnlySpan < byte > currentSlice = local . Slice ( propertyLength ) ;
407407 if ( ! currentSlice . TryGetIndex ( out int index , out int bytesConsumed ) )
408408 {
409409 return false ;
410410 }
411- Annotations [ index ] . Patch . Set ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , value ) ;
411+ ContentParts [ index ] . Patch . Set ( [ .. "$"u8 , .. currentSlice . Slice ( bytesConsumed ) ] , value ) ;
412412 return true ;
413413 }
414414 return false ;
0 commit comments