mirror of
https://github.com/TabbyML/tabby
synced 2024-11-22 08:21:59 +00:00
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:
parent
aed6574e9a
commit
910367fecb
@ -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" {
|
||||
(Some(FIM_TEMPLATE.to_owned()), None)
|
||||
} else {
|
||||
(model.prompt_template.clone(), model.chat_template.clone())
|
||||
match model.kind.as_str() {
|
||||
x if x == "mistral/completion" || OPENAI_LEGACY_COMPLETION_FIM_ALIASES.contains(&x) => {
|
||||
(Some(FIM_TEMPLATE.to_owned()), None)
|
||||
}
|
||||
_ => (model.prompt_template.clone(), model.chat_template.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user