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
c250939e
Unverified
Commit
c250939e
authored
May 18, 2025
by
ybyang
Committed by
GitHub
May 17, 2025
Browse files
[Fix Chat API] add request id for chat/completion for tracing (#6364)
parent
b6909aa2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
python/sglang/srt/openai_api/adapter.py
python/sglang/srt/openai_api/adapter.py
+4
-1
python/sglang/srt/openai_api/protocol.py
python/sglang/srt/openai_api/protocol.py
+3
-0
No files found.
python/sglang/srt/openai_api/adapter.py
View file @
c250939e
...
@@ -1193,6 +1193,7 @@ def v1_chat_generate_request(
...
@@ -1193,6 +1193,7 @@ def v1_chat_generate_request(
top_logprobs_nums
=
top_logprobs_nums
[
0
]
top_logprobs_nums
=
top_logprobs_nums
[
0
]
modalities_list
=
modalities_list
[
0
]
modalities_list
=
modalities_list
[
0
]
lora_paths
=
lora_paths
[
0
]
lora_paths
=
lora_paths
[
0
]
request_ids
=
request_ids
[
0
]
else
:
else
:
if
tokenizer_manager
.
model_config
.
is_multimodal
:
if
tokenizer_manager
.
model_config
.
is_multimodal
:
# processor will need text input
# processor will need text input
...
@@ -1429,7 +1430,9 @@ async def v1_chat_completions(
...
@@ -1429,7 +1430,9 @@ async def v1_chat_completions(
return
create_error_response
(
"Invalid request body, error: "
,
str
(
e
))
return
create_error_response
(
"Invalid request body, error: "
,
str
(
e
))
all_requests
=
[
ChatCompletionRequest
(
**
request_json
)]
all_requests
=
[
ChatCompletionRequest
(
**
request_json
)]
created
=
int
(
time
.
time
())
created
=
int
(
time
.
time
())
adapted_request
,
request
=
v1_chat_generate_request
(
all_requests
,
tokenizer_manager
)
adapted_request
,
request
=
v1_chat_generate_request
(
all_requests
,
tokenizer_manager
,
request_ids
=
[
all_requests
[
0
].
rid
]
)
if
adapted_request
.
stream
:
if
adapted_request
.
stream
:
parser_dict
=
{}
parser_dict
=
{}
...
...
python/sglang/srt/openai_api/protocol.py
View file @
c250939e
...
@@ -392,6 +392,9 @@ class ChatCompletionRequest(BaseModel):
...
@@ -392,6 +392,9 @@ class ChatCompletionRequest(BaseModel):
stream_reasoning
:
bool
=
True
stream_reasoning
:
bool
=
True
chat_template_kwargs
:
Optional
[
Dict
]
=
None
chat_template_kwargs
:
Optional
[
Dict
]
=
None
# The request id.
rid
:
Optional
[
Union
[
List
[
str
],
str
]]
=
None
# For PD disaggregation
# For PD disaggregation
bootstrap_host
:
Optional
[
str
]
=
None
bootstrap_host
:
Optional
[
str
]
=
None
bootstrap_port
:
Optional
[
int
]
=
None
bootstrap_port
:
Optional
[
int
]
=
None
...
...
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