[2/2] [feature] support openai like classification api in router (#11670)

This commit is contained in:
ybyang
2025-10-19 10:31:08 +08:00
committed by GitHub
parent a7ae61ed77
commit d513ee93ef
14 changed files with 257 additions and 45 deletions

View File

@@ -22,6 +22,7 @@ use crate::{
core::{WorkerRegistry, WorkerType},
protocols::{
chat::ChatCompletionRequest,
classify::ClassifyRequest,
completion::CompletionRequest,
embedding::EmbeddingRequest,
generate::GenerateRequest,
@@ -329,10 +330,7 @@ impl RouterTrait for RouterManager {
} else {
(
StatusCode::OK,
serde_json::json!({
"models": models
})
.to_string(),
serde_json::json!({ "models": models }).to_string(),
)
.into_response()
}
@@ -517,6 +515,25 @@ impl RouterTrait for RouterManager {
}
}
async fn route_classify(
&self,
headers: Option<&HeaderMap>,
body: &ClassifyRequest,
model_id: Option<&str>,
) -> Response {
let router = self.select_router_for_request(headers, Some(&body.model));
if let Some(router) = router {
router.route_classify(headers, body, model_id).await
} else {
(
StatusCode::NOT_FOUND,
format!("Model '{}' not found or no router available", body.model),
)
.into_response()
}
}
fn router_type(&self) -> &'static str {
"manager"
}