Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/sglang/srt/function_call/function_call_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, tools: List[Tool], tool_call_parser: str):

self.detector = detector
self.tools = tools
self.tool_call_parser = tool_call_parser

def has_tool_call(self, text: str) -> bool:
"""
Expand Down Expand Up @@ -179,12 +180,14 @@ def get_structure_constraint(
):
strict_tag = self.get_structure_tag()
return ("structural_tag", strict_tag)
elif tool_choice == "required" or isinstance(tool_choice, ToolChoice):
elif (tool_choice == "required"
or isinstance(tool_choice, ToolChoice)
or (tool_choice == "auto" and self.tool_call_parser == "longcat")):
ebnf = self.get_ebnf(tool_choice)
return ("ebnf", ebnf) if ebnf is not None else None

def get_ebnf(
self, tool_choice: Union[ToolChoice, Literal["required"]]
self, tool_choice: Union[ToolChoice, Literal["required", "auto"]]
) -> Optional[str]:
"""
Get the EBNF grammar for the specified tool choice.
Expand Down