77import  pytest 
88import  yaml 
99
10- from  ..test_llm  import  get_model_path ,  similar 
10+ from  ..test_llm  import  get_model_path 
1111from  .openai_server  import  RemoteOpenAIServer 
1212
1313pytestmark  =  pytest .mark .threadleak (enabled = False )
@@ -25,7 +25,8 @@ def temp_extra_llm_api_options_file(request):
2525    try :
2626        extra_llm_api_options_dict  =  {
2727            "guided_decoding_backend" : "xgrammar" ,
28-             "disable_overlap_scheduler" : True ,  # Guided decoding is not supported with overlap scheduler 
28+             "disable_overlap_scheduler" :
29+             True ,  # Guided decoding is not supported with overlap scheduler 
2930        }
3031
3132        with  open (temp_file_path , "w" ) as  f :
@@ -64,8 +65,14 @@ def user_profile_schema():
6465    return  {
6566        "type" : "object" ,
6667        "properties" : {
67-             "name" : {"type" : "string" , "description" : "The full name of the user." },
68-             "age" : {"type" : "integer" , "description" : "The age of the user, in years." },
68+             "name" : {
69+                 "type" : "string" ,
70+                 "description" : "The full name of the user." 
71+             },
72+             "age" : {
73+                 "type" : "integer" ,
74+                 "description" : "The age of the user, in years." 
75+             },
6976        },
7077        "required" : ["name" , "age" ],
7178    }
@@ -77,13 +84,17 @@ def test_chat_json_schema(client: openai.OpenAI, model_name: str):
7784    Adapted from https://github.com/vllm-project/vllm/blob/aae6927be06dedbda39c6b0c30f6aa3242b84388/tests/entrypoints/openai/test_chat.py#L413 
7885    """ 
7986
80-     def  _create_and_validate_response (messages : list [dict [str , Any ]]) ->  dict [str , any ]:
87+     def  _create_and_validate_response (
88+             messages : list [dict [str , Any ]]) ->  dict [str , any ]:
8189        chat_completion  =  client .chat .completions .create (
8290            model = model_name ,
8391            messages = messages ,
8492            max_tokens = 1000 ,
8593            temperature = 0.0 ,
86-             response_format = {"type" : "json" , "schema" : user_profile_schema },
94+             response_format = {
95+                 "type" : "json" ,
96+                 "schema" : user_profile_schema 
97+             },
8798        )
8899        message  =  chat_completion .choices [0 ].message 
89100        assert  message .content  is  not None 
@@ -99,28 +110,31 @@ def _create_and_validate_response(messages: list[dict[str, Any]]) -> dict[str, a
99110        return  message_json 
100111
101112    messages  =  [
102-         {"role" : "system" , "content" : "you are a helpful assistant" },
103113        {
104-             "role" : "user" ,
105-             "content" : f"Give an example JSON for an employee profile that " 
114+             "role" : "system" ,
115+             "content" : "you are a helpful assistant" 
116+         },
117+         {
118+             "role" :
119+             "user" ,
120+             "content" :
121+             f"Give an example JSON for an employee profile that " 
106122            f"fits this schema: { user_profile_schema }  ,
107123        },
108124    ]
109125
110126    first_json  =  _create_and_validate_response (messages )
111127
112-     messages .extend (
113-         [
114-             {
115-                 "role" : "assistant" ,
116-                 "content" : first_message .content ,
117-             },
118-             {
119-                 "role" : "user" ,
120-                 "content" : "Give me another one with a different name and age." ,
121-             },
122-         ]
123-     )
128+     messages .extend ([
129+         {
130+             "role" : "assistant" ,
131+             "content" : first_message .content ,
132+         },
133+         {
134+             "role" : "user" ,
135+             "content" : "Give me another one with a different name and age." ,
136+         },
137+     ])
124138    second_json  =  _create_and_validate_response (messages )
125139
126140    assert  (
0 commit comments