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
6412c5e4
Unverified
Commit
6412c5e4
authored
Mar 13, 2025
by
Conghui Tan
Committed by
GitHub
Mar 12, 2025
Browse files
Avoid duplicated request ids in batch APIs (#4026)
Co-authored-by:
conghuitan
<
conghuitan@tencent.com
>
parent
0c020860
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
+4
-10
python/sglang/srt/openai_api/adapter.py
python/sglang/srt/openai_api/adapter.py
+4
-10
No files found.
python/sglang/srt/openai_api/adapter.py
View file @
6412c5e4
...
...
@@ -284,11 +284,11 @@ async def process_batch(tokenizer_manager, batch_id: str, batch_request: BatchRe
file_request_list
=
[]
all_requests
=
[]
request_ids
=
[]
for
line
in
lines
:
for
line
_id
,
line
in
enumerate
(
lines
)
:
request_data
=
json
.
loads
(
line
)
file_request_list
.
append
(
request_data
)
body
=
request_data
[
"body"
]
request_ids
.
append
(
request_data
[
"custom
_id"
]
)
request_ids
.
append
(
f
"
{
batch_id
}
-req_
{
line
_id
}
"
)
# Although streaming is supported for standalone completions, it is not supported in
# batch mode (multiple completions in single request).
...
...
@@ -438,15 +438,9 @@ async def cancel_batch(tokenizer_manager, batch_id: str, input_file_id: str):
with
open
(
input_file_path
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
lines
=
f
.
readlines
()
file_request_list
=
[]
request_ids
=
[]
for
line
in
lines
:
request_data
=
json
.
loads
(
line
)
file_request_list
.
append
(
request_data
)
request_ids
.
append
(
request_data
[
"custom_id"
])
# Cancel requests by request_ids
for
rid
in
request_ids
:
for
line_id
in
range
(
len
(
lines
)):
rid
=
f
"
{
batch_id
}
-req_
{
line_id
}
"
tokenizer_manager
.
abort_request
(
rid
=
rid
)
retrieve_batch
=
batch_storage
[
batch_id
]
...
...
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