1515
1616
1717@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 ():
2819 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+ )
2924
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
3427
3528
3629@pytest_asyncio .fixture
@@ -316,7 +309,7 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
316309 # TODO: Add back when web search and code interpreter are available in CI
317310 prompts = [
318311 "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." ,
320313 # "When did Jensen found NVIDIA? Search it and answer the year only.",
321314 ]
322315
@@ -329,12 +322,7 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
329322 # {
330323 # "type": "web_search_preview"
331324 # },
332- # {
333- # "type": "code_interpreter",
334- # "container": {
335- # "type": "auto"
336- # }
337- # },
325+ {"type" : "code_interpreter" , "container" : {"type" : "auto" }},
338326 ],
339327 stream = True ,
340328 background = background ,
@@ -412,6 +400,7 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
412400 async for event in stream :
413401 counter += 1
414402 assert event == events [counter ]
403+ assert counter == len (events ) - 1
415404
416405
417406@pytest .mark .asyncio
@@ -429,7 +418,6 @@ async def test_web_search(client: OpenAI, model_name: str):
429418
430419@pytest .mark .asyncio
431420@pytest .mark .parametrize ("model_name" , [MODEL_NAME ])
432- @pytest .mark .skip (reason = "Code interpreter tool is not available in CI yet." )
433421async def test_code_interpreter (client : OpenAI , model_name : str ):
434422 response = await client .responses .create (
435423 model = model_name ,
@@ -443,10 +431,16 @@ async def test_code_interpreter(client: OpenAI, model_name: str):
443431 "and you must print to see the output."
444432 ),
445433 tools = [{"type" : "code_interpreter" , "container" : {"type" : "auto" }}],
434+ temperature = 0.0 , # More deterministic output in response
446435 )
447436 assert response is not None
448437 assert response .status == "completed"
449438 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
450444
451445
452446def get_weather (latitude , longitude ):
0 commit comments