@@ -112,7 +112,7 @@ public virtual async Task<ClientResult<Assistant>> CreateAssistantAsync(string m
112112 options ??= new ( ) ;
113113 options . Model = model ;
114114
115- ClientResult protocolResult = await CreateAssistantAsync ( options ? . ToBinaryContent ( ) , cancellationToken . ToRequestOptions ( ) ) . ConfigureAwait ( false ) ;
115+ ClientResult protocolResult = await CreateAssistantAsync ( options ? . ToBinaryContent ( ) , cancellationToken . ToRequestOptions ( ) ) . ConfigureAwait ( false ) ;
116116 return ClientResult . FromValue ( ( Assistant ) protocolResult , protocolResult . GetRawResponse ( ) ) ;
117117 }
118118
@@ -128,7 +128,7 @@ public virtual ClientResult<Assistant> CreateAssistant(string model, AssistantCr
128128 options . Model = model ;
129129
130130 ClientResult protocolResult = CreateAssistant ( options ? . ToBinaryContent ( ) , cancellationToken . ToRequestOptions ( ) ) ;
131- return ClientResult . FromValue ( ( Assistant ) protocolResult , protocolResult . GetRawResponse ( ) ) ;
131+ return ClientResult . FromValue ( ( Assistant ) protocolResult , protocolResult . GetRawResponse ( ) ) ;
132132 }
133133
134134 /// <summary>
@@ -231,7 +231,7 @@ public virtual ClientResult<AssistantDeletionResult> DeleteAssistant(string assi
231231 public virtual async Task < ClientResult < AssistantThread > > CreateThreadAsync ( ThreadCreationOptions options = null , CancellationToken cancellationToken = default )
232232 {
233233 ClientResult protocolResult = await CreateThreadAsync ( options ? . ToBinaryContent ( ) , cancellationToken . ToRequestOptions ( ) ) . ConfigureAwait ( false ) ;
234- return ClientResult . FromValue ( ( AssistantThread ) protocolResult , protocolResult . GetRawResponse ( ) ) ; ;
234+ return ClientResult . FromValue ( ( AssistantThread ) protocolResult , protocolResult . GetRawResponse ( ) ) ; ;
235235 }
236236
237237 /// <summary>
@@ -404,41 +404,7 @@ public virtual AsyncCollectionResult<ThreadMessage> GetMessagesAsync(
404404 string threadId ,
405405 MessageCollectionOptions options = default ,
406406 CancellationToken cancellationToken = default )
407- {
408- Argument . AssertNotNullOrEmpty ( threadId , nameof ( threadId ) ) ;
409-
410- AsyncCollectionResult result = GetMessagesAsync ( threadId , options ? . PageSizeLimit , options ? . Order ? . ToString ( ) , options ? . AfterId , options ? . BeforeId , cancellationToken . ToRequestOptions ( ) ) ;
411-
412- if ( result is not AsyncCollectionResult < ThreadMessage > collection )
413- {
414- throw new InvalidOperationException ( "Failed to cast protocol return type to expected collection type 'AsyncCollectionResult<ThreadMessage>'." ) ;
415- }
416-
417- return collection ;
418- }
419-
420- /// <summary>
421- /// Rehydrates a page collection of <see cref="ThreadMessage"/> instances from a page token.
422- /// </summary>
423- /// <param name="firstPageToken"> Page token corresponding to the first page of the collection to rehydrate. </param>
424- /// <param name="cancellationToken">A token that can be used to cancel this method call.</param>
425- /// <returns> A collection of <see cref="ThreadMessage"/>. </returns>
426- public virtual AsyncCollectionResult < ThreadMessage > GetMessagesAsync (
427- ContinuationToken firstPageToken ,
428- CancellationToken cancellationToken = default )
429- {
430- Argument . AssertNotNull ( firstPageToken , nameof ( firstPageToken ) ) ;
431-
432- MessageCollectionPageToken pageToken = MessageCollectionPageToken . FromToken ( firstPageToken ) ;
433- AsyncCollectionResult result = GetMessagesAsync ( pageToken ? . ThreadId , pageToken ? . Limit , pageToken ? . Order , pageToken ? . After , pageToken ? . Before , cancellationToken . ToRequestOptions ( ) ) ;
434-
435- if ( result is not AsyncCollectionResult < ThreadMessage > collection )
436- {
437- throw new InvalidOperationException ( "Failed to cast protocol return type to expected collection type 'AsyncCollectionResult<ThreadMessage>'." ) ;
438- }
439-
440- return collection ;
441- }
407+ => _messageSubClient . GetMessagesAsync ( threadId , options , cancellationToken ) ;
442408
443409 /// <summary>
444410 /// Gets a page collection holding <see cref="ThreadMessage"/> instances from an existing <see cref="AssistantThread"/>.
@@ -451,42 +417,7 @@ public virtual CollectionResult<ThreadMessage> GetMessages(
451417 string threadId ,
452418 MessageCollectionOptions options = default ,
453419 CancellationToken cancellationToken = default )
454- {
455- Argument . AssertNotNullOrEmpty ( threadId , nameof ( threadId ) ) ;
456-
457- CollectionResult result = GetMessages ( threadId , options ? . PageSizeLimit , options ? . Order ? . ToString ( ) , options ? . AfterId , options ? . BeforeId , cancellationToken . ToRequestOptions ( ) ) ;
458-
459- if ( result is not CollectionResult < ThreadMessage > collection )
460- {
461- throw new InvalidOperationException ( "Failed to cast protocol return type to expected collection type 'CollectionResult<ThreadMessage>'." ) ;
462- }
463-
464- return collection ;
465- }
466-
467- /// <summary>
468- /// Rehydrates a page collection holding <see cref="ThreadMessage"/> instances from a page token.
469- /// </summary>
470- /// <param name="firstPageToken"> Page token corresponding to the first page of the collection to rehydrate. </param>
471- /// <param name="cancellationToken">A token that can be used to cancel this method call.</param>
472- /// <returns> A collection of <see cref="ThreadMessage"/>. </returns>
473- public virtual CollectionResult < ThreadMessage > GetMessages (
474- ContinuationToken firstPageToken ,
475- CancellationToken cancellationToken = default )
476- {
477- Argument . AssertNotNull ( firstPageToken , nameof ( firstPageToken ) ) ;
478-
479- MessageCollectionPageToken pageToken = MessageCollectionPageToken . FromToken ( firstPageToken ) ;
480- CollectionResult result = GetMessages ( pageToken ? . ThreadId , pageToken ? . Limit , pageToken ? . Order , pageToken ? . After , pageToken ? . Before , cancellationToken . ToRequestOptions ( ) ) ;
481-
482- if ( result is not CollectionResult < ThreadMessage > collection )
483- {
484- throw new InvalidOperationException ( "Failed to cast protocol return type to expected collection type 'CollectionResult<ThreadMessage>'." ) ;
485- }
486-
487- return collection ;
488-
489- }
420+ => _messageSubClient . GetMessages ( threadId , options , cancellationToken ) ;
490421
491422 /// <summary>
492423 /// Gets an existing <see cref="ThreadMessage"/> from a known <see cref="AssistantThread"/>.
@@ -629,7 +560,7 @@ public virtual ClientResult<ThreadRun> CreateRun(string threadId, string assista
629560 options . Stream = null ;
630561
631562 ClientResult protocolResult = CreateRun ( threadId , options ? . ToBinaryContent ( ) , cancellationToken . ToRequestOptions ( ) ) ;
632- return ClientResult . FromValue ( ( ThreadRun ) protocolResult , protocolResult . GetRawResponse ( ) ) ;
563+ return ClientResult . FromValue ( ( ThreadRun ) protocolResult , protocolResult . GetRawResponse ( ) ) ;
633564 }
634565
635566 /// <summary>
0 commit comments