Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
39d01eac
Unverified
Commit
39d01eac
authored
May 27, 2025
by
ishandhanani
Committed by
GitHub
May 27, 2025
Browse files
feat(http): add health check endpoint (#1037)
parent
5c5cec3d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
0 deletions
+83
-0
lib/llm/src/discovery/model_manager.rs
lib/llm/src/discovery/model_manager.rs
+4
-0
lib/llm/src/http/service.rs
lib/llm/src/http/service.rs
+1
-0
lib/llm/src/http/service/health.rs
lib/llm/src/http/service/health.rs
+77
-0
lib/llm/src/http/service/service_v2.rs
lib/llm/src/http/service/service_v2.rs
+1
-0
No files found.
lib/llm/src/discovery/model_manager.rs
View file @
39d01eac
...
@@ -58,6 +58,10 @@ impl ModelManager {
...
@@ -58,6 +58,10 @@ impl ModelManager {
}
}
}
}
pub
fn
get_model_entries
(
&
self
)
->
Vec
<
ModelEntry
>
{
self
.entries
.lock
()
.unwrap
()
.values
()
.cloned
()
.collect
()
}
pub
fn
has_model_any
(
&
self
,
model
:
&
str
)
->
bool
{
pub
fn
has_model_any
(
&
self
,
model
:
&
str
)
->
bool
{
self
.chat_completion_engines
.read
()
.unwrap
()
.contains
(
model
)
self
.chat_completion_engines
.read
()
.unwrap
()
.contains
(
model
)
||
self
.completion_engines
.read
()
.unwrap
()
.contains
(
model
)
||
self
.completion_engines
.read
()
.unwrap
()
.contains
(
model
)
...
...
lib/llm/src/http/service.rs
View file @
39d01eac
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
mod
openai
;
mod
openai
;
pub
mod
error
;
pub
mod
error
;
pub
mod
health
;
pub
mod
metrics
;
pub
mod
metrics
;
pub
mod
service_v2
;
pub
mod
service_v2
;
...
...
lib/llm/src/http/service/health.rs
0 → 100644
View file @
39d01eac
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use
super
::{
service_v2
,
RouteDoc
};
use
axum
::{
http
::
Method
,
http
::
StatusCode
,
response
::
IntoResponse
,
routing
::
get
,
Json
,
Router
};
use
serde_json
::
json
;
use
std
::
sync
::
Arc
;
pub
fn
health_check_router
(
state
:
Arc
<
service_v2
::
State
>
,
path
:
Option
<
String
>
,
)
->
(
Vec
<
RouteDoc
>
,
Router
)
{
let
path
=
path
.unwrap_or_else
(||
"/health"
.to_string
());
let
docs
:
Vec
<
RouteDoc
>
=
vec!
[
RouteDoc
::
new
(
Method
::
GET
,
&
path
)];
let
router
=
Router
::
new
()
.route
(
&
path
,
get
(
health_handler
))
.with_state
(
state
);
(
docs
,
router
)
}
async
fn
health_handler
(
axum
::
extract
::
State
(
state
):
axum
::
extract
::
State
<
Arc
<
service_v2
::
State
>>
,
)
->
impl
IntoResponse
{
let
model_entries
=
state
.manager
()
.get_model_entries
();
if
model_entries
.is_empty
()
{
(
StatusCode
::
SERVICE_UNAVAILABLE
,
Json
(
json!
({
"status"
:
"unhealthy"
,
"message"
:
"No endpoints available"
})),
)
}
else
{
let
endpoints
:
Vec
<
String
>
=
model_entries
.iter
()
.map
(|
entry
|
entry
.endpoint
.as_url
())
.collect
();
(
StatusCode
::
OK
,
Json
(
json!
({
"status"
:
"healthy"
,
"endpoints"
:
endpoints
})),
)
}
}
lib/llm/src/http/service/service_v2.rs
View file @
39d01eac
...
@@ -147,6 +147,7 @@ impl HttpServiceConfigBuilder {
...
@@ -147,6 +147,7 @@ impl HttpServiceConfigBuilder {
let
mut
routes
=
vec!
[
let
mut
routes
=
vec!
[
metrics
::
router
(
registry
,
None
),
metrics
::
router
(
registry
,
None
),
super
::
openai
::
list_models_router
(
state
.clone
(),
None
),
super
::
openai
::
list_models_router
(
state
.clone
(),
None
),
super
::
health
::
health_check_router
(
state
.clone
(),
None
),
];
];
if
config
.enable_chat_endpoints
{
if
config
.enable_chat_endpoints
{
...
...
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