15
15
16
16
17
17
@pytest .fixture (scope = "module" )
18
- def monkeypatch_module ():
19
- from _pytest .monkeypatch import MonkeyPatch
20
-
21
- mpatch = MonkeyPatch ()
22
- yield mpatch
23
- mpatch .undo ()
24
-
25
-
26
- @pytest .fixture (scope = "module" )
27
- def server (monkeypatch_module : pytest .MonkeyPatch ):
18
+ def server ():
28
19
args = ["--enforce-eager" , "--tool-server" , "demo" ]
20
+ env_dict = dict (
21
+ VLLM_ENABLE_RESPONSES_API_STORE = "1" ,
22
+ PYTHON_EXECUTION_BACKEND = "dangerously_use_uv" ,
23
+ )
29
24
30
- with monkeypatch_module .context () as m :
31
- m .setenv ("VLLM_ENABLE_RESPONSES_API_STORE" , "1" )
32
- with RemoteOpenAIServer (MODEL_NAME , args ) as remote_server :
33
- yield remote_server
25
+ with RemoteOpenAIServer (MODEL_NAME , args , env_dict = env_dict ) as remote_server :
26
+ yield remote_server
34
27
35
28
36
29
@pytest_asyncio .fixture
@@ -316,7 +309,7 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
316
309
# TODO: Add back when web search and code interpreter are available in CI
317
310
prompts = [
318
311
"tell me a story about a cat in 20 words" ,
319
- # "What is 13 * 24? Use python to calculate the result.",
312
+ "What is 13 * 24? Use python to calculate the result." ,
320
313
# "When did Jensen found NVIDIA? Search it and answer the year only.",
321
314
]
322
315
@@ -329,12 +322,7 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
329
322
# {
330
323
# "type": "web_search_preview"
331
324
# },
332
- # {
333
- # "type": "code_interpreter",
334
- # "container": {
335
- # "type": "auto"
336
- # }
337
- # },
325
+ {"type" : "code_interpreter" , "container" : {"type" : "auto" }},
338
326
],
339
327
stream = True ,
340
328
background = background ,
@@ -412,6 +400,7 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
412
400
async for event in stream :
413
401
counter += 1
414
402
assert event == events [counter ]
403
+ assert counter == len (events ) - 1
415
404
416
405
417
406
@pytest .mark .asyncio
@@ -429,7 +418,6 @@ async def test_web_search(client: OpenAI, model_name: str):
429
418
430
419
@pytest .mark .asyncio
431
420
@pytest .mark .parametrize ("model_name" , [MODEL_NAME ])
432
- @pytest .mark .skip (reason = "Code interpreter tool is not available in CI yet." )
433
421
async def test_code_interpreter (client : OpenAI , model_name : str ):
434
422
response = await client .responses .create (
435
423
model = model_name ,
@@ -443,10 +431,16 @@ async def test_code_interpreter(client: OpenAI, model_name: str):
443
431
"and you must print to see the output."
444
432
),
445
433
tools = [{"type" : "code_interpreter" , "container" : {"type" : "auto" }}],
434
+ temperature = 0.0 , # More deterministic output in response
446
435
)
447
436
assert response is not None
448
437
assert response .status == "completed"
449
438
assert response .usage .output_tokens_details .tool_output_tokens > 0
439
+ for item in response .output :
440
+ if item .type == "message" :
441
+ output_string = item .content [0 ].text
442
+ print ("output_string: " , output_string , flush = True )
443
+ assert "5846" in output_string
450
444
451
445
452
446
def get_weather (latitude , longitude ):
0 commit comments