Skip to content

hub 0.1.5

Install from the command line:
Learn more about npm packages
$ npm install @huggingface/hub@0.1.5
Install via package.json:
"@huggingface/hub": "0.1.5"

About this version

🤗 Hugging Face Hub API

Official utilities to use the Hugging Face hub API, still very experimental.

npm add @huggingface/hub

Check out the full documentation.

API

import { createRepo, createCommit, deleteRepo, listFiles } from "@huggingface/hub";
import type { RepoId, Credentials } from "@huggingface/hub";

const repo: RepoId = { type: "model", name: "myname/some-model" };
const credentials: Credentials = { accessToken: "hf_..." };

await createRepo({ repo, credentials, license: "mit" });

await commit({
  repo,
  credentials,
  operations: [
    {
      operation: "addOrUpdate",
      path: "file.txt",
      content: new Blob(["Hello World"]),
    },
  ],
});

await (await downloadFile({ repo, path: "README.md" })).text();

for await (const fileInfo of listFiles({repo})) {
  console.log(fileInfo);
}

await deleteRepo({ repo, credentials });

Performance considerations

When uploading large files, you may want to run the commit calls inside a worker, to offload the sha256 computations.

Also, use Blob to avoid loading the whole files in RAM. In Node, it's up to you to provide a smart Blob wrapper around your file. Feel free to open an issue if you want us to provide the smart Blob implementation.

Dependencies

  • hash-wasm : Only used in the browser, when committing files over 10 MB. Browsers do not natively support streaming sha256 computations.

Details


Assets

  • hub-0.1.5.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0