Merge pull request #2452 from continuedev/tomasz/fix-ollama-fim

Fix ollama fim
This commit is contained in:
Nate Sesti 2024-10-03 10:32:37 -07:00 • committed by GitHub
commit 82e3e24603
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,8 @@ class Ollama extends BaseLLM {
model: "codellama-7b",
};
private fimSupported: boolean = false;
constructor(options: LLMOptions) {
super(options);
@ -70,6 +72,13 @@ class Ollama extends BaseLLM {
}
}
}
/**
* There is no API to get the model's FIM capabilities, so we have to
* make an educated guess. If a ".Suffix" variable appears in the template
* it's a good indication the model supports FIM.
*/
this.fimSupported = !!body?.template?.includes(".Suffix");
})
.catch((e) => {
// console.warn("Error calling the Ollama /api/show endpoint: ", e);
@ -251,7 +260,7 @@ class Ollama extends BaseLLM {
}
supportsFim(): boolean {
return true;
return this.fimSupported;
}
protected async *_streamFim(