From 7d84a61801452f5ba73527361029b01067dacc04 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Tue, 10 Dec 2024 22:57:06 +0530 Subject: [PATCH 1/4] console error fix due to duplicate keys --- app/components/chat/ModelSelector.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/chat/ModelSelector.tsx b/app/components/chat/ModelSelector.tsx index 435f4ba..bd41eb4 100644 --- a/app/components/chat/ModelSelector.tsx +++ b/app/components/chat/ModelSelector.tsx @@ -121,8 +121,8 @@ export const ModelSelector = ({ > {[...modelList] .filter((e) => e.provider == provider?.name && e.name) - .map((modelOption) => ( - ))} From af09104c824baa6a3057193f225d5713062e0d6c Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Tue, 10 Dec 2024 23:02:54 +0530 Subject: [PATCH 2/4] moved log to only print on change, and changed error logs to warnings --- app/components/chat/BaseChat.tsx | 4 +++- app/utils/constants.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index 1da80d6..99120b3 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -147,7 +147,9 @@ export const BaseChat = React.forwardRef( return () => clearInterval(interval); }, [PROVIDER_LIST]); - console.log(transcript); + useEffect(() => { + console.log(transcript); + },[transcript]) useEffect(() => { // Load API keys from cookies on component mount try { diff --git a/app/utils/constants.ts b/app/utils/constants.ts index eb90f29..1205bd6 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -384,7 +384,7 @@ async function getOllamaModels(): Promise { maxTokenAllowed: 8000, })); } catch (e) { - console.error('Error getting Ollama models:', e); + console.warn('Failed to get Ollama models:', e); return []; } } @@ -472,7 +472,7 @@ async function getLMStudioModels(): Promise { provider: 'LMStudio', })); } catch (e) { - console.error('Error getting LMStudio models:', e); + console.warn('Failed to get LMStudio models:', e); return []; } } From e0c5c51e560c5cbbcf417bbebf1ebcbf3a4d4c36 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Tue, 10 Dec 2024 23:03:12 +0530 Subject: [PATCH 3/4] lint fix --- app/components/chat/BaseChat.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index 99120b3..0d8933b 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -149,7 +149,7 @@ export const BaseChat = React.forwardRef( useEffect(() => { console.log(transcript); - },[transcript]) + }, [transcript]); useEffect(() => { // Load API keys from cookies on component mount try { From 7ba734571e32f8f324f9916cf8d2b70aff6b4956 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Tue, 10 Dec 2024 23:09:59 +0530 Subject: [PATCH 4/4] some more logs cleanup --- app/utils/constants.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/utils/constants.ts b/app/utils/constants.ts index 1205bd6..0cd0808 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -1,6 +1,7 @@ import Cookies from 'js-cookie'; import type { ModelInfo, OllamaApiResponse, OllamaModel } from './types'; import type { ProviderInfo } from '~/types/model'; +import { createScopedLogger } from './logger'; export const WORK_DIR_NAME = 'project'; export const WORK_DIR = `/home/${WORK_DIR_NAME}`; @@ -10,6 +11,8 @@ export const PROVIDER_REGEX = /\[Provider: (.*?)\]\n\n/; export const DEFAULT_MODEL = 'claude-3-5-sonnet-latest'; export const PROMPT_COOKIE_KEY = 'cachedPrompt'; +const logger = createScopedLogger('Constants'); + const PROVIDER_LIST: ProviderInfo[] = [ { name: 'Anthropic', @@ -383,8 +386,8 @@ async function getOllamaModels(): Promise { provider: 'Ollama', maxTokenAllowed: 8000, })); - } catch (e) { - console.warn('Failed to get Ollama models:', e); + } catch (e: any) { + logger.warn('Failed to get Ollama models: ', e.message || ''); return []; } } @@ -471,8 +474,8 @@ async function getLMStudioModels(): Promise { label: model.id, provider: 'LMStudio', })); - } catch (e) { - console.warn('Failed to get LMStudio models:', e); + } catch (e: any) { + logger.warn('Failed to get LMStudio models: ', e.message || ''); return []; } } @@ -491,7 +494,7 @@ async function initializeModelList(): Promise { } } } catch (error: any) { - console.warn(`Failed to fetch apikeys from cookies:${error?.message}`); + logger.warn(`Failed to fetch apikeys from cookies: ${error?.message}`); } MODEL_LIST = [ ...(