From 7ba734571e32f8f324f9916cf8d2b70aff6b4956 Mon Sep 17 00:00:00 2001 From: Anirban Kar Date: Tue, 10 Dec 2024 23:09:59 +0530 Subject: [PATCH] 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 1205bd62..0cd08081 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 = [ ...(