Skip to content

Commit acb99d1

Browse files
authored
Merge branch 'main' into templated-inference-python-snippets
2 parents 274dfe2 + e51d001 commit acb99d1

File tree

8 files changed

+60
-7
lines changed

8 files changed

+60
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or
9797
```html
9898
<script type="module">
9999
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm';
100-
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected].1/+esm";
100+
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected].2/+esm";
101101
</script>
102102
```
103103

packages/hub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@huggingface/hub",
33
"packageManager": "[email protected]",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"description": "Utilities to interact with the Hugging Face hub",
66
"repository": "https://github.com/huggingface/huggingface.js.git",
77
"publishConfig": {

packages/hub/src/lib/download-file-to-cache-dir.spec.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,47 @@ describe("downloadFileToCacheDir", () => {
114114
expect(output).toBe(expectPointer);
115115
});
116116

117+
test("existing symlinked and blob with default revision should not re-download it", async () => {
118+
// <cache>/<repo>/<revision>/snapshots/README.md
119+
const expectPointer = _getSnapshotFile({
120+
repo: DUMMY_REPO,
121+
path: "/README.md",
122+
revision: "main",
123+
});
124+
// stat ensure a symlink and the pointed file exists
125+
vi.mocked(stat).mockResolvedValue({} as Stats); // prevent default mocked reject
126+
vi.mocked(lstat).mockResolvedValue({} as Stats);
127+
vi.mocked(pathsInfo).mockResolvedValue([
128+
{
129+
oid: DUMMY_ETAG,
130+
size: 55,
131+
path: "README.md",
132+
type: "file",
133+
lastCommit: {
134+
date: new Date(),
135+
id: "main",
136+
title: "Commit msg",
137+
},
138+
},
139+
]);
140+
141+
const output = await downloadFileToCacheDir({
142+
repo: DUMMY_REPO,
143+
path: "/README.md",
144+
fetch: fetchMock,
145+
});
146+
147+
expect(stat).toHaveBeenCalledOnce();
148+
expect(symlink).not.toHaveBeenCalledOnce();
149+
// Get call argument for stat
150+
const starArg = vi.mocked(stat).mock.calls[0][0];
151+
152+
expect(starArg).toBe(expectPointer);
153+
expect(fetchMock).not.toHaveBeenCalledWith();
154+
155+
expect(output).toBe(expectPointer);
156+
});
157+
117158
test("existing blob should only create the symlink", async () => {
118159
// <cache>/<repo>/<revision>/snapshots/README.md
119160
const expectPointer = _getSnapshotFile({
@@ -150,7 +191,6 @@ describe("downloadFileToCacheDir", () => {
150191
fetch: fetchMock,
151192
});
152193

153-
expect(stat).not.toHaveBeenCalled();
154194
// should have check for the blob
155195
expect(lstat).toHaveBeenCalled();
156196
expect(vi.mocked(lstat).mock.calls[0][0]).toBe(expectedBlob);

packages/hub/src/lib/download-file-to-cache-dir.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export async function downloadFileToCacheDir(
9696
const pointerPath = getFilePointer(storageFolder, commitHash ?? pathsInformation[0].lastCommit.id, params.path);
9797
const blobPath = join(storageFolder, "blobs", etag);
9898

99+
// if we have the pointer file, we can shortcut the download
100+
if (await exists(pointerPath, true)) return pointerPath;
101+
99102
// mkdir blob and pointer path parent directory
100103
await mkdir(dirname(blobPath), { recursive: true });
101104
await mkdir(dirname(pointerPath), { recursive: true });

packages/tasks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@huggingface/tasks",
33
"packageManager": "[email protected]",
4-
"version": "0.17.1",
4+
"version": "0.17.3",
55
"description": "List of ML tasks for huggingface.co/tasks",
66
"repository": "https://github.com/huggingface/huggingface.js.git",
77
"publishConfig": {

packages/tasks/src/model-libraries.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
398398
prettyLabel: "Hunyuan3D-2",
399399
repoName: "Hunyuan3D-2",
400400
repoUrl: "https://github.com/Tencent/Hunyuan3D-2",
401-
countDownloads: `path:"model_index.json" OR path:"config.yaml"`,
401+
countDownloads: `path_filename:"model_index" OR path_filename:"config"`,
402402
},
403403
imstoucan: {
404404
prettyLabel: "IMS Toucan",
@@ -909,6 +909,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
909909
docsUrl: "https://github.com/jasonppy/VoiceCraft",
910910
snippets: snippets.voicecraft,
911911
},
912+
wham: {
913+
prettyLabel: "WHAM",
914+
repoName: "wham",
915+
repoUrl: "https://huggingface.co/microsoft/wham",
916+
docsUrl: "https://huggingface.co/microsoft/wham/blob/main/README.md",
917+
countDownloads: `path_extension:"ckpt"`,
918+
},
912919
whisperkit: {
913920
prettyLabel: "WhisperKit",
914921
repoName: "WhisperKit",

packages/tasks/src/tasks/chat-completion/inference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export interface ChatCompletionStreamOutputDelta {
273273
content?: string;
274274
role: string;
275275
tool_call_id?: string;
276-
tool_calls?: ChatCompletionStreamOutputDeltaToolCall;
276+
tool_calls?: ChatCompletionStreamOutputDeltaToolCall[];
277277
[property: string]: unknown;
278278
}
279279
export interface ChatCompletionStreamOutputDeltaToolCall {

packages/tasks/src/tasks/chat-completion/spec/stream_output.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@
104104
"example": "assistant"
105105
},
106106
"tool_calls": {
107-
"$ref": "#/$defs/ChatCompletionStreamOutputDeltaToolCall"
107+
"type": "array",
108+
"items": {
109+
"$ref": "#/$defs/ChatCompletionStreamOutputDeltaToolCall"
110+
}
108111
}
109112
},
110113
"title": "ChatCompletionStreamOutputToolCallDelta"

0 commit comments

Comments
 (0)