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

Code before:
mod azure;
mod llama;
mod openai;

use core::panic;
use std::sync::Arc;

use azure::AzureEmbeddingEngine;
use llama::LlamaCppEngine;
use openai::OpenAIEmbeddingEngine;
use tabby_common::config::HttpModelConfig;
use tabby_inference::Embedding;

use super::rate_limit;

pub async fn create(config: &HttpModelConfig) -> Arc<dyn Embedding> {
    let engine = match config.kind.as_str() {
        "llama.cpp/embedding" => LlamaCppEngine::create(
            config
                .api_endpoint
                .as_deref()
                .expect("api_endpoint is required"),
            config.api_key.clone(),
            false,
        ),
        "llama.cpp/legacy_embedding" => LlamaCppEngine::create(
            config
                .api_endpoint
                .as_deref()
                .expect("api_endpoint is required"),
            config.api_key.clone(),
            true,
        ),
        "openai/embedding" => OpenAIEmbeddingEngine::create(
            config
                .api_endpoint
                .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"),

Review comment (suggestion):
```suggestion
        "llama.cpp/before_b3xxxx_embedding" => LlamaCppEngine::create(
```

explicit naming of version for easier configuration.

Code after:
mod azure;
mod llama;
mod openai;

use core::panic;
use std::sync::Arc;

use azure::AzureEmbeddingEngine;
use llama::LlamaCppEngine;
use openai::OpenAIEmbeddingEngine;
use tabby_common::config::HttpModelConfig;
use tabby_inference::Embedding;

use super::rate_limit;

pub async fn create(config: &HttpModelConfig) -> Arc<dyn Embedding> {
    let engine = match config.kind.as_str() {
        "llama.cpp/embedding" => LlamaCppEngine::create(
            config
                .api_endpoint
                .as_deref()
                .expect("api_endpoint is required"),
            config.api_key.clone(),
            false,
        ),
        "llama.cpp/before_b4356_embedding" => LlamaCppEngine::create(
            config
                .api_endpoint
                .as_deref()
                .expect("api_endpoint is required"),
            config.api_key.clone(),
            true,
        ),
        "openai/embedding" => OpenAIEmbeddingEngine::create(
            config
                .api_endpoint
                .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"),