Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
6807af8f
Unverified
Commit
6807af8f
authored
Aug 12, 2025
by
Chen Zhang
Committed by
GitHub
Aug 12, 2025
Browse files
[gpt-oss] upgrade gpt-oss to v0.0.3 and add version check (#22768)
Signed-off-by:
Chen Zhang
<
zhangch99@outlook.com
>
parent
4c558cf6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
17 deletions
+34
-17
vllm/entrypoints/tool.py
vllm/entrypoints/tool.py
+34
-17
No files found.
vllm/entrypoints/tool.py
View file @
6807af8f
...
...
@@ -2,9 +2,7 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
os
from
abc
import
ABC
,
abstractmethod
from
typing
import
TYPE_CHECKING
,
Any
,
Optional
from
openai_harmony
import
Message
from
typing
import
TYPE_CHECKING
,
Any
from
vllm.logger
import
init_logger
...
...
@@ -15,6 +13,30 @@ if TYPE_CHECKING:
logger
=
init_logger
(
__name__
)
def
validate_gpt_oss_install
():
"""
Check if the gpt-oss is installed and its version is at least 0.0.3.
If not, raise an ImportError.
"""
from
importlib.metadata
import
PackageNotFoundError
,
version
from
packaging.version
import
InvalidVersion
,
Version
try
:
pkg_version_str
=
version
(
"gpt_oss"
)
# e.g., "0.0.5"
pkg_version
=
Version
(
pkg_version_str
)
except
PackageNotFoundError
:
raise
ImportError
(
"Package 'gpt_oss' is not installed."
)
from
None
except
InvalidVersion
as
e
:
raise
ImportError
(
f
"Invalid version string for 'gpt_oss':
{
e
}
"
)
from
None
if
pkg_version
<
Version
(
"0.0.3"
):
raise
ImportError
(
f
"gpt_oss >= 0.0.3 is required, but
{
pkg_version
}
is installed."
)
from
None
class
Tool
(
ABC
):
@
abstractmethod
...
...
@@ -33,12 +55,14 @@ class HarmonyBrowserTool(Tool):
return
try
:
validate_gpt_oss_install
()
from
gpt_oss.tools.simple_browser
import
SimpleBrowserTool
from
gpt_oss.tools.simple_browser.backend
import
ExaBackend
except
ImportError
:
except
ImportError
as
e
:
self
.
enabled
=
False
logger
.
warning_once
(
"gpt_oss is not installed, browsing is disabled"
)
"gpt_oss is not installed properly (%s), browsing is disabled"
,
e
)
return
browser_backend
=
ExaBackend
(
source
=
"web"
,
api_key
=
exa_api_key
)
...
...
@@ -65,23 +89,16 @@ class HarmonyPythonTool(Tool):
self
.
enabled
=
True
try
:
validate_gpt_oss_install
()
from
gpt_oss.tools.python_docker.docker_tool
import
PythonTool
except
ImportError
:
except
ImportError
as
e
:
self
.
enabled
=
False
logger
.
warning_once
(
"gpt_oss is not installed, code interpreter is disabled"
)
"gpt_oss is not installed properly (%s), code interpreter is "
"disabled"
,
e
)
return
# NOTE (Chen): as of gpt-oss 0.0.2, there is a bug in _make_response
# and we do the following monkey patch to fix it.
class
PatchedGptOssPythonTool
(
PythonTool
):
def
_make_response
(
self
,
output
:
str
,
channel
:
Optional
[
str
]
=
None
)
->
Message
:
return
super
().
_make_response
(
output
)
self
.
python_tool
=
PatchedGptOssPythonTool
()
self
.
python_tool
=
PythonTool
()
logger
.
info_once
(
"Code interpreter tool initialized"
)
async
def
get_result
(
self
,
context
:
"ConversationContext"
)
->
Any
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment