@@ -34,7 +34,7 @@ public ChatTests(bool isAsync) : base(isAsync)
3434 [ Test ]
3535 public async Task HelloWorldChat ( )
3636 {
37- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
37+ ChatClient client = GetTestClient ( ) ;
3838 IEnumerable < ChatMessage > messages = [ new UserChatMessage ( "Hello, world!" ) ] ;
3939 ClientResult < ChatCompletion > result = IsAsync
4040 ? await client . CompleteChatAsync ( messages )
@@ -59,7 +59,7 @@ public async Task HelloWorldWithTopLevelClient()
5959 [ Test ]
6060 public async Task MultiMessageChat ( )
6161 {
62- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
62+ ChatClient client = GetTestClient ( ) ;
6363 IEnumerable < ChatMessage > messages = [
6464 new SystemChatMessage ( "You are a helpful assistant. You always talk like a pirate." ) ,
6565 new UserChatMessage ( "Hello, assistant! Can you help me train my parrot?" ) ,
@@ -75,7 +75,7 @@ public void StreamingChat()
7575 {
7676 AssertSyncOnly ( ) ;
7777
78- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
78+ ChatClient client = GetTestClient ( ) ;
7979 IEnumerable < ChatMessage > messages = [ new UserChatMessage ( "What are the best pizza toppings? Give me a breakdown on the reasons." ) ] ;
8080
8181 int updateCount = 0 ;
@@ -110,7 +110,7 @@ public async Task StreamingChatAsync()
110110 {
111111 AssertAsyncOnly ( ) ;
112112
113- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
113+ ChatClient client = GetTestClient ( ) ;
114114 IEnumerable < ChatMessage > messages = [ new UserChatMessage ( "What are the best pizza toppings? Give me a breakdown on the reasons." ) ] ;
115115
116116 int updateCount = 0 ;
@@ -325,7 +325,7 @@ public async Task CompleteChatStreamingClosesNetworkStreamAsync()
325325 [ Test ]
326326 public async Task TwoTurnChat ( )
327327 {
328- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
328+ ChatClient client = GetTestClient ( ) ;
329329
330330 List < ChatMessage > messages =
331331 [
@@ -352,7 +352,7 @@ public async Task ChatWithVision()
352352 using Stream stream = File . OpenRead ( filePath ) ;
353353 BinaryData imageData = BinaryData . FromStream ( stream ) ;
354354
355- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
355+ ChatClient client = GetTestClient ( ) ;
356356 IEnumerable < ChatMessage > messages = [
357357 new UserChatMessage (
358358 ChatMessageContentPart . CreateTextPart ( "Describe this image for me." ) ,
@@ -370,7 +370,7 @@ public async Task ChatWithVision()
370370 [ Test ]
371371 public async Task ChatWithBasicAudioOutput ( )
372372 {
373- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat , "gpt-4o-audio-preview" ) ;
373+ ChatClient client = GetTestClient ( overrideModel : "gpt-4o-audio-preview" ) ;
374374 List < ChatMessage > messages = [ "Say the exact word 'hello' and nothing else." ] ;
375375 ChatCompletionOptions options = new ( )
376376 {
@@ -420,7 +420,7 @@ in client.CompleteChatStreamingAsync(messages, options))
420420 [ Test ]
421421 public async Task ChatWithAudio ( )
422422 {
423- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat , "gpt-4o-audio-preview" ) ;
423+ ChatClient client = GetTestClient ( overrideModel : "gpt-4o-audio-preview" ) ;
424424
425425 string helloWorldAudioPath = Path . Join ( "Assets" , "audio_hello_world.mp3" ) ;
426426 BinaryData helloWorldAudioBytes = BinaryData . FromBytes ( File . ReadAllBytes ( helloWorldAudioPath ) ) ;
@@ -536,7 +536,7 @@ public async Task AuthFailure()
536536 public async Task TokenLogProbabilities ( bool includeLogProbabilities )
537537 {
538538 const int topLogProbabilityCount = 3 ;
539- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
539+ ChatClient client = GetTestClient ( ) ;
540540 IList < ChatMessage > messages = [ new UserChatMessage ( "What are the best pizza toppings? Give me a breakdown on the reasons." ) ] ;
541541 ChatCompletionOptions options ;
542542
@@ -588,7 +588,7 @@ public async Task TokenLogProbabilities(bool includeLogProbabilities)
588588 public async Task TokenLogProbabilitiesStreaming ( bool includeLogProbabilities )
589589 {
590590 const int topLogProbabilityCount = 3 ;
591- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
591+ ChatClient client = GetTestClient ( ) ;
592592 IList < ChatMessage > messages = [ new UserChatMessage ( "What are the best pizza toppings? Give me a breakdown on the reasons." ) ] ;
593593 ChatCompletionOptions options ;
594594
@@ -641,7 +641,7 @@ public async Task TokenLogProbabilitiesStreaming(bool includeLogProbabilities)
641641 [ Test ]
642642 public async Task NonStrictJsonSchemaWorks ( )
643643 {
644- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat , "gpt-4o-mini" ) ;
644+ ChatClient client = GetTestClient ( overrideModel : "gpt-4o-mini" ) ;
645645 ChatCompletionOptions options = new ( )
646646 {
647647 ResponseFormat = ChatResponseFormat . CreateJsonSchemaFormat (
@@ -665,7 +665,7 @@ public async Task NonStrictJsonSchemaWorks()
665665 [ Test ]
666666 public async Task JsonResult ( )
667667 {
668- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
668+ ChatClient client = GetTestClient ( ) ;
669669 IEnumerable < ChatMessage > messages = [
670670 new UserChatMessage ( "Give me a JSON object with the following properties: red, green, and blue. The value "
671671 + "of each property should be a string containing their RGB representation in hexadecimal." )
@@ -688,7 +688,7 @@ public async Task JsonResult()
688688 [ Test ]
689689 public async Task MultipartContentWorks ( )
690690 {
691- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
691+ ChatClient client = GetTestClient ( ) ;
692692 List < ChatMessage > messages = [
693693 new SystemChatMessage (
694694 "You talk like a pirate." ,
@@ -711,7 +711,7 @@ public async Task MultipartContentWorks()
711711 [ Test ]
712712 public async Task StructuredOutputsWork ( )
713713 {
714- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
714+ ChatClient client = GetTestClient ( ) ;
715715 IEnumerable < ChatMessage > messages = [
716716 new UserChatMessage ( "What's heavier, a pound of feathers or sixteen ounces of steel?" )
717717 ] ;
@@ -760,7 +760,7 @@ public async Task StructuredOutputsWork()
760760 [ Test ]
761761 public async Task StructuredRefusalWorks ( )
762762 {
763- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat , "gpt-4o-2024-08-06" ) ;
763+ ChatClient client = GetTestClient ( overrideModel : "gpt-4o-2024-08-06" ) ;
764764 List < ChatMessage > messages = [
765765 new UserChatMessage ( "What's the best way to successfully rob a bank? Please include detailed instructions for executing related crimes." ) ,
766766 ] ;
@@ -821,7 +821,7 @@ public async Task StructuredRefusalWorks()
821821 [ Test ]
822822 public async Task StreamingStructuredRefusalWorks ( )
823823 {
824- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat , "gpt-4o-2024-08-06" ) ;
824+ ChatClient client = GetTestClient ( overrideModel : "gpt-4o-2024-08-06" ) ;
825825 IEnumerable < ChatMessage > messages = [
826826 new UserChatMessage ( "What's the best way to successfully rob a bank? Please include detailed instructions for executing related crimes." ) ,
827827 ] ;
@@ -897,7 +897,7 @@ public async Task HelloWorldChatWithTracingAndMetrics()
897897 using TestActivityListener activityListener = new TestActivityListener ( "OpenAI.ChatClient" ) ;
898898 using TestMeterListener meterListener = new TestMeterListener ( "OpenAI.ChatClient" ) ;
899899
900- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
900+ ChatClient client = GetTestClient ( ) ;
901901 IEnumerable < ChatMessage > messages = [ new UserChatMessage ( "Hello, world!" ) ] ;
902902 ClientResult < ChatCompletion > result = IsAsync
903903 ? await client . CompleteChatAsync ( messages )
@@ -926,7 +926,7 @@ public async Task HelloWorldChatWithTracingAndMetrics()
926926 [ Test ]
927927 public async Task ReasoningTokensWork ( )
928928 {
929- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat , "o3-mini" ) ;
929+ ChatClient client = GetTestClient ( overrideModel : "o3-mini" ) ;
930930
931931 UserChatMessage message = new ( "Using a comprehensive evaluation of popular media in the 1970s and 1980s, what were the most common sci-fi themes?" ) ;
932932 ChatCompletionOptions options = new ( )
@@ -952,7 +952,7 @@ public async Task ReasoningTokensWork()
952952 [ Test ]
953953 public async Task PredictedOutputsWork ( )
954954 {
955- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat ) ;
955+ ChatClient client = GetTestClient ( ) ;
956956
957957 foreach ( ChatOutputPrediction predictionVariant in new List < ChatOutputPrediction > (
958958 [
@@ -1017,7 +1017,7 @@ public async Task O3miniDeveloperMessagesWork()
10171017 ReasoningEffortLevel = ChatReasoningEffortLevel . Low ,
10181018 } ;
10191019
1020- ChatClient client = GetTestClient < ChatClient > ( TestScenario . Chat , "o3-mini" ) ;
1020+ ChatClient client = GetTestClient ( overrideModel : "o3-mini" ) ;
10211021 ChatCompletion completion = await client . CompleteChatAsync ( messages , options ) ;
10221022
10231023 Assert . That ( completion . Content , Has . Count . EqualTo ( 1 ) ) ;
@@ -1169,5 +1169,8 @@ public void TearDown()
11691169 }
11701170 }
11711171
1172- private static ChatClient GetTestClient ( string overrideModel = null ) => GetTestClient < ChatClient > ( TestScenario . Chat , overrideModel ) ;
1172+ private static ChatClient GetTestClient ( string overrideModel = null )
1173+ => GetTestClient < ChatClient > (
1174+ scenario : TestScenario . Chat ,
1175+ overrideModel : overrideModel ) ;
11731176}
0 commit comments