From 12dcb8deb32f3d08075071e33711ecdc94852532 Mon Sep 17 00:00:00 2001 From: Sujal Shah Date: Mon, 25 Nov 2024 17:54:29 +0530 Subject: [PATCH] fix: add browser environment check for local API calls --- app/utils/constants.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/utils/constants.ts b/app/utils/constants.ts index 6645020be..17fe9d8af 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -283,6 +283,10 @@ const getOllamaBaseUrl = () => { }; async function getOllamaModels(): Promise { + if (typeof window === 'undefined') { + return []; + } + try { const baseUrl = getOllamaBaseUrl(); const response = await fetch(`${baseUrl}/api/tags`); @@ -361,6 +365,10 @@ async function getOpenRouterModels(): Promise { } async function getLMStudioModels(): Promise { + if (typeof window === 'undefined') { + return []; + } + try { const baseUrl = import.meta.env.LMSTUDIO_API_BASE_URL || 'http://localhost:1234'; const response = await fetch(`${baseUrl}/v1/models`);