fix(completion): should build fim prompt for openai aliases (#3341)

* fix: should build fim completion prompt for openai aliases

* chore: update fim list name

Co-authored-by: Meng Zhang <meng@tabbyml.com>

---------

Co-authored-by: Meng Zhang <meng@tabbyml.com>
This commit is contained in:
Wei Zhang 2024-10-31 00:54:32 +08:00 committed by GitHub
parent aed6574e9a
commit 910367fecb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,7 +31,7 @@ pub async fn create(model: &HttpModelConfig) -> Arc<dyn CompletionStream> {
);
Arc::new(engine)
}
"openai/legacy_completion" | "openai/completion" | "deepseek/completion" => {
x if OPENAI_LEGACY_COMPLETION_FIM_ALIASES.contains(&x) => {
let engine = OpenAICompletionEngine::create(
model.model_name.clone(),
model
@ -64,12 +64,18 @@ pub async fn create(model: &HttpModelConfig) -> Arc<dyn CompletionStream> {
const FIM_TOKEN: &str = "<|FIM|>";
const FIM_TEMPLATE: &str = "{prefix}<|FIM|>{suffix}";
const OPENAI_LEGACY_COMPLETION_FIM_ALIASES: [&str; 3] = [
"openai/legacy_completion",
"openai/completion",
"deepseek/completion",
];
pub fn build_completion_prompt(model: &HttpModelConfig) -> (Option<String>, Option<String>) {
if model.kind == "mistral/completion" || model.kind == "openai/completion" {
match model.kind.as_str() {
x if x == "mistral/completion" || OPENAI_LEGACY_COMPLETION_FIM_ALIASES.contains(&x) => {
(Some(FIM_TEMPLATE.to_owned()), None)
} else {
(model.prompt_template.clone(), model.chat_template.clone())
}
_ => (model.prompt_template.clone(), model.chat_template.clone()),
}
}