Unverified Commit a9064c51 authored by Schwinn Saereesitthipitak's avatar Schwinn Saereesitthipitak Committed by GitHub
Browse files

fix: hide inactive models from /v1/models (#6966)

parent b07be71b
...@@ -152,6 +152,31 @@ impl Model { ...@@ -152,6 +152,31 @@ impl Model {
.any(|entry| entry.value().has_videos_engine()) .any(|entry| entry.value().has_videos_engine())
} }
/// Whether this model should be visible in /v1/models.
pub fn is_displayable(&self) -> bool {
let has_serving_engine = |ws: &WorkerSet| {
ws.has_chat_engine()
|| ws.has_completions_engine()
|| ws.has_embeddings_engine()
|| ws.has_images_engine()
|| ws.has_tensor_engine()
|| ws.has_videos_engine()
};
let has_any_serving_engine = self.worker_sets.iter().any(|entry| {
let ws = entry.value();
has_serving_engine(ws.as_ref())
});
self.worker_sets.iter().any(|entry| {
let ws = entry.value();
if ws.worker_count() == 0 {
return false;
}
has_serving_engine(ws.as_ref()) || (!has_any_serving_engine && ws.is_prefill_set())
})
}
/// Check if a candidate checksum is valid for this model. /// Check if a candidate checksum is valid for this model.
/// Returns `Some(true)` if it matches the canonical checksum, `Some(false)` if it /// Returns `Some(true)` if it matches the canonical checksum, `Some(false)` if it
/// doesn't match, or `None` if no canonical checksum has been set yet (no WorkerSets). /// doesn't match, or `None` if no canonical checksum has been set yet (no WorkerSets).
......
...@@ -194,21 +194,11 @@ impl ModelManager { ...@@ -194,21 +194,11 @@ impl ModelManager {
} }
pub fn model_display_names(&self) -> HashSet<String> { pub fn model_display_names(&self) -> HashSet<String> {
let mut names = HashSet::new(); self.models
for entry in self.models.iter() { .iter()
let model = entry.value(); .filter(|entry| entry.value().is_displayable())
if model.has_chat_engine() .map(|entry| entry.key().clone())
|| model.has_completions_engine() .collect()
|| model.has_embeddings_engine()
|| model.has_images_engine()
|| model.has_tensor_engine()
|| model.has_videos_engine()
|| model.has_prefill()
{
names.insert(entry.key().clone());
}
}
names
} }
pub fn list_chat_completions_models(&self) -> Vec<String> { pub fn list_chat_completions_models(&self) -> Vec<String> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment