You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/utils/hub.js
+10-16Lines changed: 10 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
// Utility functions to interact with the Hugging Face Hub (https://huggingface.co/models)
2
2
3
3
// const path = require('file-system-cache');
4
-
const{ env }=require('../env.js');
5
-
constfs=require('fs');
4
+
import{env}from'../env.js';
5
+
importfsfrom'fs';
6
6
7
-
const{ dispatchCallback }=require('../utils.js');
8
-
constpath=require('path');
7
+
import{dispatchCallback}from'../utils.js';
8
+
importpathfrom'path';
9
9
10
10
/**
11
11
* @typedef {object} PretrainedOptions Options for loading a pretrained model.
@@ -198,7 +198,7 @@ function isValidHttpUrl(string) {
198
198
* @param {URL|string} urlOrPath - The URL/path of the file to get.
199
199
* @returns {Promise<FileResponse|Response>} A promise that resolves to a FileResponse object (if the file is retrieved using the FileSystem API), or a Response object (if the file is retrieved using the Fetch API).
200
200
*/
201
-
asyncfunctiongetFile(urlOrPath){
201
+
exportasyncfunctiongetFile(urlOrPath){
202
202
// Helper function to get a file, using either the Fetch API or FileSystem API
203
203
204
204
if(env.useFS&&!isValidHttpUrl(urlOrPath)){
@@ -321,7 +321,7 @@ class FileCache {
321
321
* @throws Will throw an error if the file is not found and `fatal` is true.
322
322
* @returns {Promise} A Promise that resolves with the file content as a buffer.
0 commit comments