@@ -25,7 +25,7 @@ public async void Get_simple_structured_response_from_ChatGPT()
2525 }
2626
2727 [ Fact ]
28- public async void Get_structured_response_with_array_from_ChatGPT ( )
28+ public async void Get_structured_response_with_ARRAY_from_ChatGPT ( )
2929 {
3030 var message =
3131 Dialog . StartAsSystem ( "What did user input?" )
@@ -43,16 +43,36 @@ public async void Get_structured_response_with_array_from_ChatGPT()
4343 response . Items [ 1 ] . Quantity . Should ( ) . Be ( 3 ) ;
4444 }
4545
46+ [ Fact ]
47+ public async void Get_structured_response_with_ENUM_from_ChatGPT ( )
48+ {
49+ var message =
50+ Dialog . StartAsSystem ( "What did user input?" )
51+ . ThenUser ( "Мой любимый цвет - красный" ) ;
52+ var response = await _client . GetStructuredResponse < Thing > ( message ) ;
53+ response . Should ( ) . NotBeNull ( ) ;
54+ response . Color . Should ( ) . Be ( Thing . Colors . Red ) ;
55+ }
56+
57+ [ Fact ]
58+ public async void Get_structured_response_with_extra_data_from_ChatGPT ( )
59+ {
60+ var message =
61+ Dialog . StartAsSystem ( "Just answer the questions." )
62+ . ThenUser ( "In what year was the city of Almaty originally founded?" ) ;
63+ var response = await _client . GetStructuredResponse < City > ( message ) ;
64+ response . Should ( ) . NotBeNull ( ) ;
65+ response . Name . Should ( ) . Be ( "Almaty" ) ;
66+ response . YearOfFoundation . Should ( ) . Be ( 1854 ) ;
67+ response . Country . Should ( ) . Be ( "Kazakhstan" ) ;
68+ }
69+
4670 private class Order
4771 {
4872 public UserInfo UserInfo { get ; set ; }
4973 public List < Item > Items { get ; set ; }
5074
51- public class Item
52- {
53- public string Name { get ; set ; } = "" ;
54- public int Quantity { get ; set ; }
55- }
75+ public record Item ( string Name , int Quantity ) ;
5676 }
5777
5878 private class UserInfo
@@ -61,4 +81,18 @@ private class UserInfo
6181 public int Age { get ; init ; }
6282 public string Email { get ; init ; }
6383 }
84+
85+ private record Thing ( Thing . Colors Color )
86+ {
87+ public enum Colors
88+ {
89+ None ,
90+ Red ,
91+ Green ,
92+ Blue
93+ }
94+ }
95+
96+ private record City ( string Name , int YearOfFoundation , string Country ) ;
6497}
98+
0 commit comments