Skip to content

Commit 91ac7f7

Browse files
authored
[CI][gpt-oss] Enable python tool tests in CI (#24315)
Signed-off-by: wuhang <[email protected]>
1 parent 4be7d7c commit 91ac7f7

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

requirements/common.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ pybase64 # fast base64 implementation
4949
cbor2 # Required for cross-language serialization of hashable objects
5050
setproctitle # Used to set process names for better debugging and monitoring
5151
openai-harmony >= 0.0.3 # Required for gpt-oss
52+
gpt-oss >= 0.0.7

tests/entrypoints/openai/test_response_api_with_harmony.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,15 @@
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.")
433421
async 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

452446
def get_weather(latitude, longitude):

vllm/entrypoints/tool.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,30 @@
1414

1515
logger = init_logger(__name__)
1616

17+
MIN_GPT_OSS_VERSION = "0.0.7"
18+
1719

1820
def validate_gpt_oss_install():
1921
"""
20-
Check if the gpt-oss is installed and its version is at least 0.0.3.
22+
Check if the gpt-oss is installed and its version is at least 0.0.7.
2123
If not, raise an ImportError.
2224
"""
2325
from importlib.metadata import PackageNotFoundError, version
2426

2527
from packaging.version import InvalidVersion, Version
2628

2729
try:
28-
pkg_version_str = version("gpt_oss") # e.g., "0.0.5"
30+
pkg_version_str = version("gpt_oss")
2931
pkg_version = Version(pkg_version_str)
3032
except PackageNotFoundError:
3133
raise ImportError("Package 'gpt_oss' is not installed.") from None
3234
except InvalidVersion as e:
3335
raise ImportError(f"Invalid version string for 'gpt_oss': {e}") from None
3436

35-
if pkg_version < Version("0.0.3"):
37+
if pkg_version < Version(MIN_GPT_OSS_VERSION):
3638
raise ImportError(
37-
f"gpt_oss >= 0.0.3 is required, but {pkg_version} is installed."
39+
f"gpt_oss >= {MIN_GPT_OSS_VERSION} is required, "
40+
f"but {pkg_version} is installed."
3841
) from None
3942

4043

0 commit comments

Comments
 (0)