mirror of
https://github.com/katanemo/plano.git
synced 2026-05-24 14:05:14 +02:00
don't include internal models in /v1/models endpoint (#685)
This commit is contained in:
parent
c1c808feb2
commit
ab391f96c7
3 changed files with 49 additions and 2 deletions
|
|
@ -310,6 +310,7 @@ def validate_and_render_schema():
|
||||||
"name": "arch-router",
|
"name": "arch-router",
|
||||||
"provider_interface": "arch",
|
"provider_interface": "arch",
|
||||||
"model": config_yaml.get("routing", {}).get("model", "Arch-Router"),
|
"model": config_yaml.get("routing", {}).get("model", "Arch-Router"),
|
||||||
|
"internal": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -320,6 +321,7 @@ def validate_and_render_schema():
|
||||||
"name": "arch-function",
|
"name": "arch-function",
|
||||||
"provider_interface": "arch",
|
"provider_interface": "arch",
|
||||||
"model": "Arch-Function",
|
"model": "Arch-Function",
|
||||||
|
"internal": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -329,6 +331,7 @@ def validate_and_render_schema():
|
||||||
"name": "plano-orchestrator",
|
"name": "plano-orchestrator",
|
||||||
"provider_interface": "arch",
|
"provider_interface": "arch",
|
||||||
"model": "Plano-Orchestrator",
|
"model": "Plano-Orchestrator",
|
||||||
|
"internal": True,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,7 @@ pub struct LlmProvider {
|
||||||
pub routing_preferences: Option<Vec<RoutingPreference>>,
|
pub routing_preferences: Option<Vec<RoutingPreference>>,
|
||||||
pub cluster_name: Option<String>,
|
pub cluster_name: Option<String>,
|
||||||
pub base_url_path_prefix: Option<String>,
|
pub base_url_path_prefix: Option<String>,
|
||||||
|
pub internal: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait IntoModels {
|
pub trait IntoModels {
|
||||||
|
|
@ -333,6 +334,7 @@ impl IntoModels for Vec<LlmProvider> {
|
||||||
fn into_models(self) -> Models {
|
fn into_models(self) -> Models {
|
||||||
let data = self
|
let data = self
|
||||||
.iter()
|
.iter()
|
||||||
|
.filter(|provider| provider.internal != Some(true))
|
||||||
.map(|provider| ModelDetail {
|
.map(|provider| ModelDetail {
|
||||||
id: provider.name.clone(),
|
id: provider.name.clone(),
|
||||||
object: Some("model".to_string()),
|
object: Some("model".to_string()),
|
||||||
|
|
@ -364,6 +366,7 @@ impl Default for LlmProvider {
|
||||||
routing_preferences: None,
|
routing_preferences: None,
|
||||||
cluster_name: None,
|
cluster_name: None,
|
||||||
base_url_path_prefix: None,
|
base_url_path_prefix: None,
|
||||||
|
internal: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -479,6 +482,7 @@ mod test {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use super::{IntoModels, LlmProvider, LlmProviderType};
|
||||||
use crate::api::open_ai::ToolType;
|
use crate::api::open_ai::ToolType;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -561,4 +565,42 @@ mod test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_into_models_filters_internal_providers() {
|
||||||
|
let providers = vec![
|
||||||
|
LlmProvider {
|
||||||
|
name: "openai-gpt4".to_string(),
|
||||||
|
provider_interface: LlmProviderType::OpenAI,
|
||||||
|
model: Some("gpt-4".to_string()),
|
||||||
|
internal: None,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
LlmProvider {
|
||||||
|
name: "arch-router".to_string(),
|
||||||
|
provider_interface: LlmProviderType::Arch,
|
||||||
|
model: Some("Arch-Router".to_string()),
|
||||||
|
internal: Some(true),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
LlmProvider {
|
||||||
|
name: "plano-orchestrator".to_string(),
|
||||||
|
provider_interface: LlmProviderType::Arch,
|
||||||
|
model: Some("Plano-Orchestrator".to_string()),
|
||||||
|
internal: Some(true),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
let models = providers.into_models();
|
||||||
|
|
||||||
|
// Should only have 1 model: openai-gpt4
|
||||||
|
assert_eq!(models.data.len(), 1);
|
||||||
|
|
||||||
|
// Verify internal models are excluded from /v1/models
|
||||||
|
let model_ids: Vec<String> = models.data.iter().map(|m| m.id.clone()).collect();
|
||||||
|
assert!(model_ids.contains(&"openai-gpt4".to_string()));
|
||||||
|
assert!(!model_ids.contains(&"arch-router".to_string()));
|
||||||
|
assert!(!model_ids.contains(&"plano-orchestrator".to_string()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,12 @@ model_providers:
|
||||||
model: ministral-3b-latest
|
model: ministral-3b-latest
|
||||||
name: mistral/ministral-3b-latest
|
name: mistral/ministral-3b-latest
|
||||||
provider_interface: mistral
|
provider_interface: mistral
|
||||||
- model: Arch-Function
|
- internal: true
|
||||||
|
model: Arch-Function
|
||||||
name: arch-function
|
name: arch-function
|
||||||
provider_interface: arch
|
provider_interface: arch
|
||||||
- model: Plano-Orchestrator
|
- internal: true
|
||||||
|
model: Plano-Orchestrator
|
||||||
name: plano-orchestrator
|
name: plano-orchestrator
|
||||||
provider_interface: arch
|
provider_interface: arch
|
||||||
prompt_targets:
|
prompt_targets:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue