diff --git a/app/utils/constants.ts b/app/utils/constants.ts index 1120bc1f2..bf1da4871 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -309,14 +309,14 @@ const getOllamaBaseUrl = () => { }; async function getOllamaModels(): Promise { - /* - * if (typeof window === 'undefined') { - * return []; - * } - */ - try { const baseUrl = getOllamaBaseUrl(); + + if (!baseUrl) { + // Breaks early if baseURL not set. Fixes "Error getting Ollama models" + return []; + } + const response = await fetch(`${baseUrl}/api/tags`); const data = (await response.json()) as OllamaApiResponse;