Skip to content

Commit 642f70e

Browse files
author
machineuser
committed
🔖 @hugginface/hub v0.4.0
1 parent 59896ce commit 642f70e

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

‎docs/hub/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ npm add @huggingface/hub
1111
For some of the calls, you need to create an account and generate an [access token](https://huggingface.co/settings/tokens).
1212

1313
```ts
14-
import { createRepo, commit, deleteRepo, listFiles, whoAmI } from "@huggingface/hub";
14+
import { createRepo, uploadFiles, deleteFile, deleteRepo, listFiles, whoAmI } from "@huggingface/hub";
1515
import type { RepoId, Credentials } from "@huggingface/hub";
1616

1717
const repo: RepoId = { type: "model", name: "myname/some-model" };
@@ -25,30 +25,30 @@ for await (const model of listModels({search: {owner: username}, credentials}))
2525

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

28-
await commit({
28+
await uploadFiles({
2929
repo,
3030
credentials,
31-
operations: [
31+
files: [
32+
// path + blob content
3233
{
33-
operation: "addOrUpdate",
3434
path: "file.txt",
3535
content: new Blob(["Hello World"]),
3636
},
37+
// Local file URL
38+
pathToFileURL("./pytorch-model.bin"),
39+
// Web URL
40+
new URL("https://huggingface.co/xlm-roberta-base/resolve/main/tokenizer.json"),
41+
// Path + Web URL
3742
{
38-
operation: "addOrUpdate",
39-
path: "pytorch-model.bin",
40-
// Only supported from the backend
41-
content: pathToFileURL("./pytorch-model.bin"),
42-
},
43-
{
44-
operation: "addOrUpdate",
45-
path: "tokenizer.json",
46-
// Copy xml-roberta-base's tokenizer.json directly from HF
47-
content: new URL("https://huggingface.co/xlm-roberta-base/raw/main/tokenizer.json"),
48-
},
43+
path: "myfile.bin",
44+
content: new URL("https://huggingface.co/bert-base-uncased/resolve/main/pytorch_model.bin")
45+
}
46+
// Can also work with native File in browsers
4947
],
5048
});
5149

50+
await deleteFile({repo, credentials, path: "myfile.bin"});
51+
5252
await (await downloadFile({ repo, path: "README.md" })).text();
5353

5454
for await (const fileInfo of listFiles({repo})) {

‎docs/hub/interfaces/CommitFile.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### content
66

7-
• **content**: `ContentSource`
7+
• **content**: [`ContentSource`](../modules#contentsource)
88

99
#### Defined in
1010

‎docs/hub/modules.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ ___
7070

7171
___
7272

73+
### ContentSource
74+
75+
Ƭ **ContentSource**: `Blob` \| `URL`
76+
77+
#### Defined in
78+
79+
[hub/src/lib/commit.ts:32](https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/commit.ts#L32)
80+
81+
___
82+
7383
### RepoType
7484

7585
Ƭ **RepoType**: ``"space"`` \| ``"dataset"`` \| ``"model"``

‎packages/hub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huggingface/hub",
3-
"version": "0.3.3",
3+
"version": "0.4.0",
44
"description": "Utilities to interact with the Hugging Face hub",
55
"repository": "https://github.com/huggingface/huggingface.js.git",
66
"publishConfig": {

0 commit comments

Comments
 (0)