From fda992366cad53726501c8ca837ffeb6e5205da5 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Thu, 3 Oct 2024 17:55:16 +0200 Subject: [PATCH] fix ollama fim --- core/llm/llms/Ollama.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 3b16d0456..f9f3ccd72 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -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(