[Bugfix][Feat] Add XML-ish grammar in EBNFComposer and fix misc bugs in Qwen3 detector (#8357)

This commit is contained in:
Chang Su
2025-07-25 12:03:16 -07:00
committed by GitHub
parent 12cb760a37
commit f8260f2539
7 changed files with 577 additions and 86 deletions
@@ -8,7 +8,6 @@ from sglang.srt.entrypoints.openai.protocol import Tool
from sglang.srt.function_call.base_format_detector import BaseFormatDetector
from sglang.srt.function_call.core_types import (
StreamingParseResult,
StructureInfo,
ToolCallItem,
_GetInfoFunc,
)
@@ -216,11 +215,11 @@ class PythonicDetector(BaseFormatDetector):
else:
raise ValueError("Tool call arguments must be literals")
def structure_info(self) -> _GetInfoFunc:
def info(name: str):
return StructureInfo(begin=f"[{name}(", end=")]", trigger=f"[{name}(")
def supports_structural_tag(self) -> bool:
return False
return info
def structure_info(self) -> _GetInfoFunc:
raise NotImplementedError
def build_ebnf(self, tools: List[Tool]) -> Optional[str]:
return EBNFComposer.build_ebnf(