Skip to content

Commit

Permalink
fix: hide gpu check windows
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Aug 7, 2024
1 parent 18c99db commit 0892f58
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 58 deletions.
12 changes: 0 additions & 12 deletions cortex-js/src/usecases/models/models.usecases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<HuggingFaceRepoData> {
if (modelId.includes('/')) return fetchHuggingFaceRepoData(modelId);
else return fetchJanRepoData(modelId);
}

/**
* Get the current status of the models
* @returns Model statuses
Expand Down
3 changes: 3 additions & 0 deletions cortex-js/src/utils/cuda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export const getGpuInfo = async (): Promise<GpuSettingInfo[]> =>
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
Expand Down
46 changes: 0 additions & 46 deletions cortex-js/src/utils/huggingface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<HuggingFaceRepoData> {
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"
Expand Down

0 comments on commit 0892f58

Please sign in to comment.