@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 6807af8f46
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[gpt-oss] upgrade gpt-oss to v0.0.3 and add version check (#22768)

Signed-off-by: Chen Zhang <zhangch99@outlook.com>

Chen Zhang committed Aug 12, 2025 at 21:37 UTC 6807af8f46acd184f99342ff38f2a1359f693b10
1 file changed +34 -17
vllm/entrypoints/tool.py
+34 -17
@@ -2,9 +2,7 @@
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 import os
4 from abc import ABC, abstractmethod
5 -from typing import TYPE_CHECKING, Any, Optional
6 -
7 -from openai_harmony import Message
5 +from typing import TYPE_CHECKING, Any
6
7 from vllm.logger import init_logger
8
@@ -15,6 +13,30 @@ if TYPE_CHECKING:
13 logger = init_logger(__name__)
14
15
16 +def validate_gpt_oss_install():
17 + """
18 + Check if the gpt-oss is installed and its version is at least 0.0.3.
19 + If not, raise an ImportError.
20 + """
21 + from importlib.metadata import PackageNotFoundError, version
22 +
23 + from packaging.version import InvalidVersion, Version
24 +
25 + try:
26 + pkg_version_str = version("gpt_oss") # e.g., "0.0.5"
27 + pkg_version = Version(pkg_version_str)
28 + except PackageNotFoundError:
29 + raise ImportError("Package 'gpt_oss' is not installed.") from None
30 + except InvalidVersion as e:
31 + raise ImportError(
32 + f"Invalid version string for 'gpt_oss': {e}") from None
33 +
34 + if pkg_version < Version("0.0.3"):
35 + raise ImportError(
36 + f"gpt_oss >= 0.0.3 is required, but {pkg_version} is installed."
37 + ) from None
38 +
39 +
40 class Tool(ABC):
41
42 @abstractmethod
@@ -33,12 +55,14 @@ class HarmonyBrowserTool(Tool):
55 return
56
57 try:
58 + validate_gpt_oss_install()
59 from gpt_oss.tools.simple_browser import SimpleBrowserTool
60 from gpt_oss.tools.simple_browser.backend import ExaBackend
38 - except ImportError:
61 + except ImportError as e:
62 self.enabled = False
63 logger.warning_once(
41 - "gpt_oss is not installed, browsing is disabled")
64 + "gpt_oss is not installed properly (%s), browsing is disabled",
65 + e)
66 return
67
68 browser_backend = ExaBackend(source="web", api_key=exa_api_key)
@@ -65,23 +89,16 @@ class HarmonyPythonTool(Tool):
89 self.enabled = True
90
91 try:
92 + validate_gpt_oss_install()
93 from gpt_oss.tools.python_docker.docker_tool import PythonTool
69 - except ImportError:
94 + except ImportError as e:
95 self.enabled = False
96 logger.warning_once(
72 - "gpt_oss is not installed, code interpreter is disabled")
97 + "gpt_oss is not installed properly (%s), code interpreter is "
98 + "disabled", e)
99 return
100
75 - # NOTE (Chen): as of gpt-oss 0.0.2, there is a bug in _make_response
76 - # and we do the following monkey patch to fix it.
77 - class PatchedGptOssPythonTool(PythonTool):
78 -
79 - def _make_response(self,
80 - output: str,
81 - channel: Optional[str] = None) -> Message:
82 - return super()._make_response(output)
83 -
84 - self.python_tool = PatchedGptOssPythonTool()
101 + self.python_tool = PythonTool()
102 logger.info_once("Code interpreter tool initialized")
103
104 async def get_result(self, context: "ConversationContext") -> Any: