From 572916ebbfa2ca27782737fc16f8bb2402c1d344 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 12 Mar 2024 23:24:56 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20error=20listing=20Ollama?= =?UTF-8?q?=20tags=20in=20JetBrains?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/llm/llms/Ollama.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 4e02a16cf..1c0c77561 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -218,9 +218,13 @@ class Ollama extends BaseLLM { } async listModels(): Promise { - const response = await this.fetch(new URL("api/tags", this.apiBase), { - method: "GET", - }); + const response = await this.fetch( + // localhost was causing fetch failed in pkg binary only for this Ollama endpoint + new URL("api/tags", this.apiBase?.replace("localhost", "127.0.0.1")), + { + method: "GET", + }, + ); const data = await response.json(); return data.models.map((model: any) => model.name); }