From 0892f58c1d995714ce3790989a31d00bd9b09f05 Mon Sep 17 00:00:00 2001 From: Louis Le Date: Wed, 7 Aug 2024 22:24:52 +0700 Subject: [PATCH] fix: hide gpu check windows --- .../src/usecases/models/models.usecases.ts | 12 ----- cortex-js/src/utils/cuda.ts | 3 ++ cortex-js/src/utils/huggingface.ts | 46 ------------------- 3 files changed, 3 insertions(+), 58 deletions(-) diff --git a/cortex-js/src/usecases/models/models.usecases.ts b/cortex-js/src/usecases/models/models.usecases.ts index f2ad2b1fb..7182436cf 100644 --- a/cortex-js/src/usecases/models/models.usecases.ts +++ b/cortex-js/src/usecases/models/models.usecases.ts @@ -17,11 +17,9 @@ import { TelemetrySource } from '@/domain/telemetry/telemetry.interface'; import { ModelRepository } from '@/domain/repositories/model.interface'; import { ModelParameterParser } from '@/utils/model-parameter.parser'; import { - HuggingFaceRepoData, HuggingFaceRepoSibling, } from '@/domain/models/huggingface.interface'; import { - fetchHuggingFaceRepoData, fetchJanRepoData, getHFModelMetadata, } from '@/utils/huggingface'; @@ -530,16 +528,6 @@ export class ModelsUsecases { else throw 'Model already exists.'; } - /** - * Fetches the model data from HuggingFace - * @param modelId Model repo id. e.g. llama3, llama3:8b, janhq/llama3 - * @returns Model metadata - */ - fetchModelMetadata(modelId: string): Promise { - if (modelId.includes('/')) return fetchHuggingFaceRepoData(modelId); - else return fetchJanRepoData(modelId); - } - /** * Get the current status of the models * @returns Model statuses diff --git a/cortex-js/src/utils/cuda.ts b/cortex-js/src/utils/cuda.ts index 679f61842..ecddbaf4f 100644 --- a/cortex-js/src/utils/cuda.ts +++ b/cortex-js/src/utils/cuda.ts @@ -109,6 +109,9 @@ export const getGpuInfo = async (): Promise => new Promise((resolve) => { exec( 'nvidia-smi --query-gpu=index,memory.total,name --format=csv,noheader,nounits', + { + windowsHide: true, + }, async (error, stdout) => { if (!error) { // Get GPU info and gpu has higher memory first diff --git a/cortex-js/src/utils/huggingface.ts b/cortex-js/src/utils/huggingface.ts index 38b642ad0..a69572992 100644 --- a/cortex-js/src/utils/huggingface.ts +++ b/cortex-js/src/utils/huggingface.ts @@ -60,52 +60,6 @@ export function guessPromptTemplateFromHuggingFace(jinjaCode?: string): string { } } -/** - * Fetches the model data from HuggingFace API - * @param repoId HuggingFace model id. e.g. "janhq/llama-3" - * @returns - */ -export async function fetchHuggingFaceRepoData( - repoId: string, -): Promise { - const sanitizedUrl = getRepoModelsUrl(repoId); - - const { data: response } = await axios.get(sanitizedUrl); - if (response['error'] != null) { - throw new Error(response['error']); - } - - const data = response as HuggingFaceRepoData; - - if (data.tags.indexOf('gguf') === -1) { - throw `${repoId} is not supported. Only GGUF models are supported.`; - } - - // fetching file sizes - const url = new URL(sanitizedUrl); - const paths = url.pathname.split('/').filter((e) => e.trim().length > 0); - - for (let i = 0; i < data.siblings.length; i++) { - const downloadUrl = HUGGING_FACE_DOWNLOAD_FILE_MAIN_URL( - [paths[2], paths[3]].join('/'), - data.siblings[i].rfilename, - ); - data.siblings[i].downloadUrl = downloadUrl; - } - - //TODO: Very hacky? Let's say they don't name it properly - AllQuantizations.forEach((quantization) => { - data.siblings.forEach((sibling: any) => { - if (!sibling.quantization && sibling.rfilename.includes(quantization)) { - sibling.quantization = quantization; - } - }); - }); - - data.modelUrl = HUGGING_FACE_REPO_URL(paths[2], paths[3]); - return data; -} - /** * Fetch the model data from Jan's repo * @param modelId HuggingFace model id. e.g. "llama-3:7b"