From f94165a421a0c97ef2b2d733e8739baf9f3cc6f9 Mon Sep 17 00:00:00 2001 From: Sujal Shah Date: Mon, 25 Nov 2024 14:00:18 +0530 Subject: [PATCH 1/2] fix: silent eslint issues --- app/components/chat/BaseChat.tsx | 3 --- app/lib/runtime/action-runner.ts | 5 ++--- app/utils/constants.ts | 6 +++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index 1a33375..19daf5b 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -29,9 +29,6 @@ const EXAMPLE_PROMPTS = [ { text: 'How do I center a div?' }, ]; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const providerList = PROVIDER_LIST; - // @ts-ignore TODO: Introduce proper types // eslint-disable-next-line @typescript-eslint/no-unused-vars const ModelSelector = ({ model, setModel, provider, setProvider, modelList, providerList, apiKeys }) => { diff --git a/app/lib/runtime/action-runner.ts b/app/lib/runtime/action-runner.ts index ca78a74..13b17ef 100644 --- a/app/lib/runtime/action-runner.ts +++ b/app/lib/runtime/action-runner.ts @@ -93,14 +93,13 @@ export class ActionRunner { this.#updateAction(actionId, { ...action, ...data.action, executed: !isStreaming }); - // eslint-disable-next-line consistent-return - return (this.#currentExecutionPromise = this.#currentExecutionPromise + this.#currentExecutionPromise = this.#currentExecutionPromise .then(() => { this.#executeAction(actionId, isStreaming); }) .catch((error) => { console.error('Action failed:', error); - })); + }); } async #executeAction(actionId: string, isStreaming: boolean = false) { diff --git a/app/utils/constants.ts b/app/utils/constants.ts index de68a82..6645020 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -294,8 +294,8 @@ async function getOllamaModels(): Promise { provider: 'Ollama', maxTokenAllowed: 8000, })); - // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { + console.error('Error getting Ollama models:', e); return []; } } @@ -321,8 +321,8 @@ async function getOpenAILikeModels(): Promise { label: model.id, provider: 'OpenAILike', })); - // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { + console.error('Error getting OpenAILike models:', e); return []; } } @@ -371,8 +371,8 @@ async function getLMStudioModels(): Promise { label: model.id, provider: 'LMStudio', })); - // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { + console.error('Error getting LMStudio models:', e); return []; } } From 12dcb8deb32f3d08075071e33711ecdc94852532 Mon Sep 17 00:00:00 2001 From: Sujal Shah Date: Mon, 25 Nov 2024 17:54:29 +0530 Subject: [PATCH 2/2] 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 6645020..17fe9d8 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`);