some more logs cleanup

This commit is contained in:
Anirban Kar 2024-12-10 23:09:59 +05:30
parent e0c5c51e56
commit 7ba734571e

View File

@ -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<ModelInfo[]> {
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<ModelInfo[]> {
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<ModelInfo[]> {
}
}
} 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 = [
...(