@@ -58,28 +58,34 @@ class NestedResponse(BaseModel):
58
58
sorted_list : List [Person ] = Field (description = "List of the sorted objects" )
59
59
60
60
61
- def get_params_and_expected_type (response_type : str ):
61
+ def get_params_and_expected_type (response_type : str , test_id : str ):
62
62
params = {}
63
63
if response_type == "basic" :
64
64
params .update (
65
65
** messages (
66
- system ("You are a helpful assistant designed to output JSON." ),
66
+ system (
67
+ f"{ test_id } You are a helpful assistant designed to output JSON."
68
+ ),
67
69
user ("Who won the world series in 2020?" ),
68
70
)
69
71
)
70
72
expected_type = BasicResponse
71
73
elif response_type == "array" :
72
74
params .update (
73
75
** messages (
74
- system ("You are a helpful assistant designed to output JSON." ),
76
+ system (
77
+ f"{ test_id } You are a helpful assistant designed to output JSON."
78
+ ),
75
79
user ("Sort the numbers 3, 1, 2, 4, 5" ),
76
80
)
77
81
)
78
82
expected_type = ArrayResponse
79
83
elif response_type == "nested" :
80
84
params .update (
81
85
** messages (
82
- system ("You are a helpful assistant designed to output JSON." ),
86
+ system (
87
+ f"{ test_id } You are a helpful assistant designed to output JSON."
88
+ ),
83
89
user (
84
90
"Sort these people by age: John, 20 years old, Mary, 30 years old, Bob, 10 years old."
85
91
),
@@ -116,11 +122,11 @@ def get_response_formats():
116
122
117
123
118
124
async def query_json_model (
119
- model : str , response_type : str , stream : bool , openai_async_client
125
+ model : str , response_type : str , stream : bool , openai_async_client , test_id : str
120
126
):
121
127
querier = TextGenerationProbeQuerier (openai_async_client , {"temperature" : 0.0 })
122
128
123
- params , expected_type = get_params_and_expected_type (response_type )
129
+ params , expected_type = get_params_and_expected_type (response_type , test_id )
124
130
response = await querier .query (model , stream = stream , ** params )
125
131
response_str = response .full ()
126
132
@@ -148,7 +154,7 @@ async def test_json_mode(
148
154
149
155
responses = await asyncio .gather (
150
156
* [
151
- query_json_model (model , response_type , stream , openai_async_client )
157
+ query_json_model (model , response_type , stream , openai_async_client , test_id )
152
158
for _ in range (n_concurrent_requests )
153
159
]
154
160
)
@@ -172,7 +178,7 @@ async def test_response_format_options(
172
178
173
179
params = {
174
180
** messages (
175
- system (" You are a helpful assistant designed to output JSON." ),
181
+ system (f" { test_id } You are a helpful assistant designed to output JSON." ),
176
182
user ("Who won the world series in 2020?" ),
177
183
),
178
184
"response_format" : response_format ,
0 commit comments