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
151e287d
Unverified
Commit
151e287d
authored
Sep 13, 2025
by
Yi Zhang
Committed by
GitHub
Sep 12, 2025
Browse files
fix: add fast path for function call (#9023)
Co-authored-by:
tazjin
<
mail@tazj.in
>
parent
8c86595c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
python/sglang/srt/function_call/function_call_parser.py
python/sglang/srt/function_call/function_call_parser.py
+6
-0
No files found.
python/sglang/srt/function_call/function_call_parser.py
View file @
151e287d
...
@@ -69,6 +69,8 @@ class FunctionCallParser:
...
@@ -69,6 +69,8 @@ class FunctionCallParser:
Returns:
Returns:
True if the text contains a tool call, False otherwise
True if the text contains a tool call, False otherwise
"""
"""
if
not
self
.
tools
:
return
False
return
self
.
detector
.
has_tool_call
(
text
)
return
self
.
detector
.
has_tool_call
(
text
)
def
parse_non_stream
(
self
,
full_text
:
str
)
->
Tuple
[
str
,
list
[
ToolCallItem
]]:
def
parse_non_stream
(
self
,
full_text
:
str
)
->
Tuple
[
str
,
list
[
ToolCallItem
]]:
...
@@ -83,6 +85,8 @@ class FunctionCallParser:
...
@@ -83,6 +85,8 @@ class FunctionCallParser:
- The remaining text after parsing that was not consumed by the detector (can be treated as normal text)
- The remaining text after parsing that was not consumed by the detector (can be treated as normal text)
- A list of tool calls parsed from the text
- A list of tool calls parsed from the text
"""
"""
if
not
self
.
tools
:
return
full_text
,
[]
parsed_result
=
self
.
detector
.
detect_and_parse
(
full_text
,
self
.
tools
)
parsed_result
=
self
.
detector
.
detect_and_parse
(
full_text
,
self
.
tools
)
tool_call_list
=
parsed_result
.
calls
tool_call_list
=
parsed_result
.
calls
if
tool_call_list
:
if
tool_call_list
:
...
@@ -102,6 +106,8 @@ class FunctionCallParser:
...
@@ -102,6 +106,8 @@ class FunctionCallParser:
- The normal text that should be displayed to the user
- The normal text that should be displayed to the user
- A list of tool calls parsed from the chunk
- A list of tool calls parsed from the chunk
"""
"""
if
not
self
.
tools
:
return
chunk_text
,
[]
final_normal_text
=
""
final_normal_text
=
""
final_calls
=
[]
final_calls
=
[]
...
...
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