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
6242c399
Unverified
Commit
6242c399
authored
Aug 21, 2024
by
Lucien
Committed by
GitHub
Aug 21, 2024
Browse files
Generate 1 token to verify the health of the inference service in /health (#1154)
Co-authored-by:
Yineng Zhang
<
me@zhyncs.com
>
parent
04707b09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
python/sglang/srt/server.py
python/sglang/srt/server.py
+17
-0
No files found.
python/sglang/srt/server.py
View file @
6242c399
...
...
@@ -89,6 +89,23 @@ app = FastAPI()
tokenizer_manager
=
None
@
app
.
get
(
"/v1/health"
)
async
def
health
(
request
:
Request
)
->
Response
:
"""
Generate 1 token to verify the health of the inference service.
"""
gri
=
GenerateReqInput
(
text
=
"s"
,
sampling_params
=
{
"max_new_tokens"
:
1
,
"temperature"
:
0.7
}
)
try
:
async
for
_
in
tokenizer_manager
.
generate_request
(
gri
,
request
):
break
return
Response
(
status_code
=
200
)
except
Exception
as
e
:
logger
.
exception
(
e
)
return
Response
(
status_code
=
503
)
@
app
.
get
(
"/health"
)
async
def
health
()
->
Response
:
"""Health check."""
...
...
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