Improve: Support xgrammar 0.1.14 (#3593)
This commit is contained in:
committed by
GitHub
parent
b0df5d240b
commit
d281587989
@@ -35,7 +35,7 @@ runtime_common = [
|
||||
"torchao>=0.7.0",
|
||||
"uvicorn",
|
||||
"uvloop",
|
||||
"xgrammar==0.1.10",
|
||||
"xgrammar==0.1.14",
|
||||
"ninja",
|
||||
"transformers==4.48.3",
|
||||
"llguidance>=0.6.15"
|
||||
|
||||
@@ -19,7 +19,6 @@ from typing import List, Tuple
|
||||
import torch
|
||||
from xgrammar import (
|
||||
CompiledGrammar,
|
||||
Grammar,
|
||||
GrammarCompiler,
|
||||
GrammarMatcher,
|
||||
TokenizerInfo,
|
||||
@@ -135,9 +134,7 @@ class XGrammarGrammarBackend(BaseGrammarBackend):
|
||||
return None
|
||||
elif key_type == "regex":
|
||||
try:
|
||||
ctx = self.grammar_compiler.compile_grammar(
|
||||
Grammar.from_regex(key_string)
|
||||
)
|
||||
ctx = self.grammar_compiler.compile_regex(key_string)
|
||||
except RuntimeError as e:
|
||||
logging.warning(f"Skip invalid regex: regex={key_string}, {e=}")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user