Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
ec1cd90a
Unverified
Commit
ec1cd90a
authored
Oct 12, 2025
by
Antoine Roux
Committed by
GitHub
Oct 12, 2025
Browse files
Fix the GPT function calling regex to allow dash in the name (#10577)
parent
1103dc62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
python/sglang/srt/function_call/gpt_oss_detector.py
python/sglang/srt/function_call/gpt_oss_detector.py
+1
-1
sgl-router/src/tool_parser/parsers/gpt_oss_parser.rs
sgl-router/src/tool_parser/parsers/gpt_oss_parser.rs
+2
-2
No files found.
python/sglang/srt/function_call/gpt_oss_detector.py
View file @
ec1cd90a
...
...
@@ -31,7 +31,7 @@ class GptOssDetector(BaseFormatDetector):
# Pattern to extract function name and JSON from tool_call event content
self
.
tool_extract_pattern
=
re
.
compile
(
r
"to=([a-zA-Z_][a-zA-Z0-9_.]*)\s*<\|constrain\|>json<\|message\|>(.*?)(?:<\|call\|>|$)"
,
r
"to=([a-zA-Z_][a-zA-Z0-9_.
-
]*)\s*<\|constrain\|>json<\|message\|>(.*?)(?:<\|call\|>|$)"
,
re
.
DOTALL
,
)
...
...
sgl-router/src/tool_parser/parsers/gpt_oss_parser.rs
View file @
ec1cd90a
...
...
@@ -40,12 +40,12 @@ impl GptOssParser {
pub
fn
new
()
->
Self
{
// Pattern for complete function calls with to= parameter
// Handles optional <|start|>assistant prefix and whitespace after function name
let
function_call_pattern
=
r"(?s)(?:<\|start\|>assistant)?<\|channel\|>commentary to=([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\s*<\|constrain\|>json<\|message\|>(.*?)<\|call\|>(?:commentary)?"
;
let
function_call_pattern
=
r"(?s)(?:<\|start\|>assistant)?<\|channel\|>commentary to=([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_
-
]*)*)\s*<\|constrain\|>json<\|message\|>(.*?)<\|call\|>(?:commentary)?"
;
let
function_call_extractor
=
Regex
::
new
(
function_call_pattern
)
.expect
(
"Valid regex pattern"
);
// Pattern for streaming function calls (incomplete)
let
streaming_pattern
=
r"(?s)(?:<\|start\|>assistant)?<\|channel\|>commentary to=([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\s*<\|constrain\|>json<\|message\|>(.*)"
;
let
streaming_pattern
=
r"(?s)(?:<\|start\|>assistant)?<\|channel\|>commentary to=([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_
-
]*)*)\s*<\|constrain\|>json<\|message\|>(.*)"
;
let
streaming_extractor
=
Regex
::
new
(
streaming_pattern
)
.expect
(
"Valid regex pattern"
);
Self
{
...
...
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