Something went wrong. Try again.
Routing embedding stack for Qwen3-Embedding-0.6B on Apple Silicon: orchestrator + MLX + llama.cpp backends
Something went wrong. Try again.
1.4 kB · 56 lines
Rust
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657use axum::{ http::StatusCode, response::{IntoResponse, Response}, Json,};use serde_json::json;use thiserror::Error;
#[derive(Debug, Error)]pub enum OrchestratorError { #[error("texts must be non-empty")] EmptyTexts,
#[error("text[{index}] exceeds context window ({tokens}>{limit})")] TextTooLong { index: usize, tokens: usize, limit: usize, },
#[error("only 0.6B is supported")] UnsupportedSize,
#[error("tokenizer error: {0}")] Tokenizer(String),
#[error("swift backend error: {0}")] Swift(String),
#[error("rust backend error: {0}")] Rust(String),
#[error("internal: {0}")] Internal(String),}
impl IntoResponse for OrchestratorError { fn into_response(self) -> Response { let status = match &self { Self::EmptyTexts | Self::TextTooLong { .. } | Self::UnsupportedSize => { StatusCode::BAD_REQUEST } Self::Tokenizer(_) | Self::Swift(_) | Self::Rust(_) | Self::Internal(_) => { StatusCode::INTERNAL_SERVER_ERROR } }; let body = Json(json!({ "error": self.to_string() })); (status, body).into_response() }}
impl From<anyhow::Error> for OrchestratorError { fn from(e: anyhow::Error) -> Self { Self::Internal(e.to_string()) }}