From 85986bb97808105840704304f906b2d3757f82e9 Mon Sep 17 00:00:00 2001 From: Yineng Zhang Date: Mon, 10 Feb 2025 01:51:30 +0800 Subject: [PATCH] compatible with new outlines (#3435) --- python/pyproject.toml | 4 ++-- python/sglang/srt/constrained/outlines_backend.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 78520d47b..830bc9575 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -25,8 +25,8 @@ runtime_common = [ ] srt = [ "sglang[runtime_common]", "cuda-python", - "sgl-kernel>=0.0.3.post2", "torch", "vllm==0.6.4.post1", - "flashinfer_python>=0.2.0.post2", "outlines>=0.0.44,<0.1.0" + "sgl-kernel>=0.0.3.post2", "torch", "vllm>=0.6.4.post1,<=0.7.2", + "flashinfer_python>=0.2.0.post2", "outlines>=0.0.44,<=0.1.11" ] # HIP (Heterogeneous-computing Interface for Portability) for AMD diff --git a/python/sglang/srt/constrained/outlines_backend.py b/python/sglang/srt/constrained/outlines_backend.py index 91dbcba24..47dd485cd 100644 --- a/python/sglang/srt/constrained/outlines_backend.py +++ b/python/sglang/srt/constrained/outlines_backend.py @@ -35,7 +35,10 @@ is_hip_ = is_hip() if is_hip_: from outlines_core.fsm.json_schema import build_regex_from_schema else: - from outlines.fsm.json_schema import build_regex_from_schema + try: + from outlines.fsm.json_schema import build_regex_from_schema + except ImportError: + from outlines_core.fsm.json_schema import build_regex_from_schema logger = logging.getLogger(__name__)