Skip to content

Commit 8c36b68

Browse files
committed
fix downloading models
1 parent a04cb02 commit 8c36b68

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mydeviceai-desktop",
33
"productName": "mydeviceai-desktop",
4-
"version": "1.6.1",
4+
"version": "1.8",
55
"description": "My Electron application description",
66
"main": ".webpack/main",
77
"scripts": {

src/modelManager.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,12 @@ export async function listHfRepoGgufFiles(
427427
throw new Error('repoId is required');
428428
}
429429

430-
const url = `https://huggingface.co/api/models/${encodeURIComponent(
431-
trimmed,
432-
)}/tree/main`;
430+
// Note: repoId should NOT be fully URL-encoded as HF expects the slash unencoded
431+
const [owner, repo] = trimmed.split('/');
432+
const encodedRepoPath = owner && repo
433+
? `${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
434+
: encodeURIComponent(trimmed); // fallback for malformed repoId
435+
const url = `https://huggingface.co/api/models/${encodedRepoPath}/tree/main`;
433436

434437
const raw = await fetchJson<any[]>(url);
435438

@@ -727,9 +730,13 @@ export async function downloadHfModel(
727730
ensureDirSync(MODEL_DIR);
728731

729732
const id = `${repoId}/${fileName}`;
730-
const url = `https://huggingface.co/${encodeURIComponent(
731-
repoId,
732-
)}/resolve/main/${encodeURIComponent(fileName)}?download=true`;
733+
// Note: repoId should NOT be fully URL-encoded as HF expects the slash unencoded
734+
// Only encode individual parts of the repo path (owner/repo)
735+
const [owner, repo] = repoId.split('/');
736+
const encodedRepoPath = owner && repo
737+
? `${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
738+
: encodeURIComponent(repoId); // fallback for malformed repoId
739+
const url = `https://huggingface.co/${encodedRepoPath}/resolve/main/${encodeURIComponent(fileName)}?download=true`;
733740

734741
const destPath = path.join(MODEL_DIR, fileName);
735742
const tmpPath = destPath + '.download';

0 commit comments

Comments
 (0)