Repository: TabbyML/tabby
File: crates/http-api-bindings/src/embedding/mod.rs (Rust)

Code before:
                .as_deref()
                .expect("api_endpoint is required"),
            config.model_name.as_deref().unwrap_or_default(),
            config.api_key.as_deref(),
        ),
        "ollama/embedding" => ollama_api_bindings::create_embedding(config).await,
        "voyage/embedding" => OpenAIEmbeddingEngine::create(
            config
                .api_endpoint
                .as_deref()
                .unwrap_or("https://api.voyageai.com/v1"),
            config
                .model_name
                .as_deref()
                .expect("model_name must be set for voyage/embedding"),
            config.api_key.as_deref(),
        ),
        "azure/embedding" => AzureEmbeddingEngine::create(
            config
                .api_endpoint
                .as_deref()
                .expect("api_endpoint is required for azure/embedding"),
            config.model_name.as_deref().unwrap_or_default(), // Provide a default if model_name is optional
            config.api_key.as_deref(),
        ),
        "codestral/embedding" => CodestralEmbeddingEngine::create(config.api_key.as_deref()),
        unsupported_kind => panic!(
            "Unsupported kind for http embedding model: {}",
            unsupported_kind
        ),
    };

    Arc::new(rate_limit::new_embedding(
        engine,
        config.rate_limit.request_per_minute,
    ))
}

#[macro_export]
macro_rules! embedding_info_span {
    ($kind:expr) => {
        tracing::info_span!("embedding", kind = $kind)
    };
}


Review comment (suggestion):
the API comes from Mistral AI, `codestral` is only the name of their model, so i prefer use the kind `mistral/embedding`

Code after:
                .as_deref()
                .expect("api_endpoint is required"),
            config.model_name.as_deref().unwrap_or_default(),
            config.api_key.as_deref(),
        ),
        "ollama/embedding" => ollama_api_bindings::create_embedding(config).await,
        "voyage/embedding" => OpenAIEmbeddingEngine::create(
            config
                .api_endpoint
                .as_deref()
                .unwrap_or("https://api.voyageai.com/v1"),
            config
                .model_name
                .as_deref()
                .expect("model_name must be set for voyage/embedding"),
            config.api_key.as_deref(),
        ),
        "azure/embedding" => AzureEmbeddingEngine::create(
            config
                .api_endpoint
                .as_deref()
                .expect("api_endpoint is required for azure/embedding"),
            config.model_name.as_deref().unwrap_or_default(), // Provide a default if model_name is optional
            config.api_key.as_deref(),
        ),
        "mistral/embedding" => MistralEmbeddingEngine::create(
            config.api_endpoint.as_deref(),
            config.model_name.as_deref(),
            config.api_key.as_deref(),
        ),
        unsupported_kind => panic!(
            "Unsupported kind for http embedding model: {}",
            unsupported_kind
        ),
    };

    Arc::new(rate_limit::new_embedding(
        engine,
        config.rate_limit.request_per_minute,
    ))
}

#[macro_export]
macro_rules! embedding_info_span {
    ($kind:expr) => {
        tracing::info_span!("embedding", kind = $kind)
    };
}