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

Code before:
                model.api_key.clone(),
            );
            Arc::new(engine)
        }
        "ollama/completion" => ollama_api_bindings::create_completion(model).await,
        "mistral/completion" => {
            let engine = MistralFIMEngine::create(
                model.api_endpoint.as_deref(),
                model.api_key.clone(),
                model.model_name.clone(),
            );
            Arc::new(engine)
        }
        "openai/completion" | "openai/legacy_completion" => {
            let engine = OpenAICompletionEngine::create(
                model.model_name.clone(),
                model
                    .api_endpoint
                    .as_deref()
                    .expect("api_endpoint is required"),
                model.api_key.clone(),
                true,
            );
            Arc::new(engine)
        }
        "openai/legacy_completion_no_fim" => {
            let engine = OpenAICompletionEngine::create(
                model.model_name.clone(),
                model
                    .api_endpoint
                    .as_deref()
                    .expect("api_endpoint is required"),
                model.api_key.clone(),
                false,
            );
            Arc::new(engine)
        }
        unsupported_kind => panic!(
            "Unsupported model kind for http completion: {}",
            unsupported_kind
        ),
    }
}

const FIM_TOKEN: &str = "
";
const FIM_TEMPLATE: &str = "{prefix}
{suffix}";

pub fn build_completion_prompt(model: &HttpModelConfig) -> (Option<String>, Option<String>) {
    if model.kind == "mistral/completion" || model.kind == "openai/completion" {
        (Some(FIM_TEMPLATE.to_owned()), None)
    } else {

Review comment (suggestion):
```suggestion
        "openai/legacy_completion_no_fim" | "vllm/completion" => {
```

Code after:
                model.api_key.clone(),
            );
            Arc::new(engine)
        }
        "ollama/completion" => ollama_api_bindings::create_completion(model).await,
        "mistral/completion" => {
            let engine = MistralFIMEngine::create(
                model.api_endpoint.as_deref(),
                model.api_key.clone(),
                model.model_name.clone(),
            );
            Arc::new(engine)
        }
        "openai/legacy_completion" | "openai/completion" | "deepseek/completion" => {
            let engine = OpenAICompletionEngine::create(
                model.model_name.clone(),
                model
                    .api_endpoint
                    .as_deref()
                    .expect("api_endpoint is required"),
                model.api_key.clone(),
                true,
            );
            Arc::new(engine)
        }
        "openai/legacy_completion_no_fim" | "vllm/completion" => {
            let engine = OpenAICompletionEngine::create(
                model.model_name.clone(),
                model
                    .api_endpoint
                    .as_deref()
                    .expect("api_endpoint is required"),
                model.api_key.clone(),
                false,
            );
            Arc::new(engine)
        }
        unsupported_kind => panic!(
            "Unsupported model kind for http completion: {}",
            unsupported_kind
        ),
    }
}

const FIM_TOKEN: &str = "
";
const FIM_TEMPLATE: &str = "{prefix}
{suffix}";

pub fn build_completion_prompt(model: &HttpModelConfig) -> (Option<String>, Option<String>) {
    if model.kind == "mistral/completion" || model.kind == "openai/completion" {
        (Some(FIM_TEMPLATE.to_owned()), None)
    } else {