Skip to content

Commit 8cf1a86

Browse files
committed
update Nscale provider
2 parents 83f8e2d + f9e360f commit 8cf1a86

File tree

334 files changed

+16286
-11521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

334 files changed

+16286
-11521
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ jobs:
6161
echo "SINCE=$(git merge-base origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }})" >> $GITHUB_OUTPUT
6262
fi
6363
64+
- run: google-chrome --version
65+
6466
- run: npm install -g corepack@latest && corepack enable
6567

6668
- uses: actions/setup-node@v3
6769
with:
68-
node-version: "20"
70+
node-version: "22"
6971
cache: "pnpm"
7072
cache-dependency-path: "**/pnpm-lock.yaml"
7173
- run: |
@@ -105,7 +107,7 @@ jobs:
105107
run: |
106108
sleep 3
107109
pnpm i --filter root --filter inference... --filter hub... --filter tasks-gen --frozen-lockfile
108-
pnpm --filter inference --filter hub --filter tasks publish --force --no-git-checks --registry http://localhost:4874/
110+
pnpm --filter inference --filter hub --filter tasks --filter jinja publish --force --no-git-checks --registry http://localhost:4874/
109111
110112
- name: E2E test - test yarn install
111113
working-directory: e2e/ts
@@ -136,7 +138,7 @@ jobs:
136138
deno-version: vx.x.x
137139
- name: E2E test - deno import from npm
138140
working-directory: e2e/deno
139-
run: deno run --allow-net --allow-env=HF_TOKEN index.ts
141+
run: deno run --allow-read --allow-net --allow-env=HF_TOKEN index.ts
140142
env:
141143
NPM_CONFIG_REGISTRY: http://localhost:4874/
142144
HF_TOKEN: ${{ secrets.HF_TOKEN }}

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ownership for the Inference Package
22

3-
/packages/inference/ @julien-c @hanouticelina @SBrandeis @coyotte508
3+
/packages/inference/ @julien-c @hanouticelina @SBrandeis
44

55
# Ownership for the Tasks Package
66

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ We use `pnpm` as our package manager. You need to use it, eg `pnpm install` inst
88

99
If you want to format the whole codebase, you can do `pnpm -r format` at the root.
1010

11-
Other than that, we avoid runtime dependencies unless they're strictly needed. For example, our only dependency is `hash-wasm`, and it's only in the browser context and when uploaded files are > 10MB.
11+
Other than that, we avoid runtime dependencies unless they're strictly needed. Even then, we prefer vendoring the code.
1212

1313
## Pull requests
1414

@@ -18,7 +18,11 @@ It's not a hard requirement, but please consider using an icon from [Gitmoji](ht
1818

1919
## Tests
2020

21-
If you want to run only specific tests, you can do `pnpm test -- -t "test name"`
21+
If you want to run only specific tests, you can do `pnpm test -- -t "test name"`.
22+
23+
You can also do `npx vitest ./packages/hub/src/utils/XetBlob.spec.ts` to run a specific test file.
24+
25+
Or `cd packages/hub && npx vitest --browser.name=chrome --browser.headless --config vitest-browser.config.mts ./src/utils/XetBlob.spec.ts` to run browser tests on a specific file
2226

2327
## Adding a package
2428

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</p>
1111

1212
```ts
13-
// Programatically interact with the Hub
13+
// Programmatically interact with the Hub
1414

1515
await createRepo({
1616
repo: { type: "model", name: "my-user/nlp-model" },
@@ -31,6 +31,7 @@ await uploadFile({
3131

3232
await inference.chatCompletion({
3333
model: "meta-llama/Llama-3.1-8B-Instruct",
34+
provider: "sambanova", // or together, fal-ai, replicate, cohere …
3435
messages: [
3536
{
3637
role: "user",
@@ -39,11 +40,11 @@ await inference.chatCompletion({
3940
],
4041
max_tokens: 512,
4142
temperature: 0.5,
42-
provider: "sambanova", // or together, fal-ai, replicate, cohere …
4343
});
4444

4545
await inference.textToImage({
4646
model: "black-forest-labs/FLUX.1-dev",
47+
provider: "replicate",
4748
inputs: "a picture of a green bird",
4849
});
4950

@@ -54,7 +55,7 @@ await inference.textToImage({
5455

5556
This is a collection of JS libraries to interact with the Hugging Face API, with TS types included.
5657

57-
- [@huggingface/inference](packages/inference/README.md): Use HF Inference API (serverless), Inference Endpoints (dedicated) and third-party Inference Providers to make calls to 100,000+ Machine Learning models
58+
- [@huggingface/inference](packages/inference/README.md): Use HF Inference API (serverless), Inference Endpoints (dedicated) and all supported Inference Providers to make calls to 100,000+ Machine Learning models
5859
- [@huggingface/hub](packages/hub/README.md): Interact with huggingface.co to create or delete repos and commit / download files
5960
- [@huggingface/agents](packages/agents/README.md): Interact with HF models through a natural language interface
6061
- [@huggingface/gguf](packages/gguf/README.md): A GGUF parser that works on remotely hosted files.
@@ -84,7 +85,7 @@ npm install @huggingface/agents
8485
Then import the libraries in your code:
8586

8687
```ts
87-
import { HfInference } from "@huggingface/inference";
88+
import { InferenceClient } from "@huggingface/inference";
8889
import { HfAgent } from "@huggingface/agents";
8990
import { createRepo, commit, deleteRepo, listFiles } from "@huggingface/hub";
9091
import type { RepoId } from "@huggingface/hub";
@@ -96,21 +97,21 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or
9697

9798
```html
9899
<script type="module">
99-
import { HfInference } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@3.5.1/+esm';
100-
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/hub@1.0.2/+esm";
100+
import { InferenceClient } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@3.7.0/+esm';
101+
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/hub@1.1.2/+esm";
101102
</script>
102103
```
103104

104105
### Deno
105106

106107
```ts
107108
// esm.sh
108-
import { HfInference } from "https://esm.sh/@huggingface/inference"
109+
import { InferenceClient } from "https://esm.sh/@huggingface/inference"
109110
import { HfAgent } from "https://esm.sh/@huggingface/agents";
110111

111112
import { createRepo, commit, deleteRepo, listFiles } from "https://esm.sh/@huggingface/hub"
112113
// or npm:
113-
import { HfInference } from "npm:@huggingface/inference"
114+
import { InferenceClient } from "npm:@huggingface/inference"
114115
import { HfAgent } from "npm:@huggingface/agents";
115116

116117
import { createRepo, commit, deleteRepo, listFiles } from "npm:@huggingface/hub"
@@ -123,11 +124,11 @@ Get your HF access token in your [account settings](https://huggingface.co/setti
123124
### @huggingface/inference examples
124125

125126
```ts
126-
import { HfInference } from "@huggingface/inference";
127+
import { InferenceClient } from "@huggingface/inference";
127128

128129
const HF_TOKEN = "hf_...";
129130

130-
const inference = new HfInference(HF_TOKEN);
131+
const inference = new InferenceClient(HF_TOKEN);
131132

132133
// Chat completion API
133134
const out = await inference.chatCompletion({
@@ -179,7 +180,7 @@ await inference.imageToText({
179180

180181
// Using your own dedicated inference endpoint: https://hf.co/docs/inference-endpoints/
181182
const gpt2 = inference.endpoint('https://xyz.eu-west-1.aws.endpoints.huggingface.cloud/gpt2');
182-
const { generated_text } = await gpt2.textGeneration({inputs: 'The answer to the universe is'});
183+
const { generated_text } = await gpt2.textGeneration({ inputs: 'The answer to the universe is' });
183184

184185
// Chat Completion
185186
const llamaEndpoint = inference.endpoint(

e2e/deno/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HfInference } from "npm:@huggingface/inference@*";
1+
import { InferenceClient } from "npm:@huggingface/inference@*";
22
import { whoAmI, listFiles } from "npm:@huggingface/hub@*";
33

44
const info = await whoAmI({ credentials: { accessToken: "hf_hub.js" }, hubUrl: "https://hub-ci.huggingface.co" });
@@ -10,7 +10,7 @@ for await (const file of listFiles({ repo: "gpt2" })) {
1010

1111
const token = Deno.env.get("HF_TOKEN");
1212
if (token) {
13-
const hf = new HfInference(token);
13+
const hf = new InferenceClient(token);
1414

1515
const tokenInfo = await whoAmI({ credentials: { accessToken: token } });
1616
console.log(tokenInfo);

e2e/svelte/src/routes/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script>
22
import { whoAmI, listFiles } from "@huggingface/hub";
3-
import { HfInference } from "@huggingface/inference";
3+
import { InferenceClient } from "@huggingface/inference";
44
5-
const hf = new HfInference();
5+
const hf = new InferenceClient();
66
77
const test = async () => {
88
const info = await whoAmI({ credentials: { accessToken: "hf_hub.js" }, hubUrl: "https://hub-ci.huggingface.co" });

e2e/ts/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { HfInference } from "@huggingface/inference";
1+
import { InferenceClient } from "@huggingface/inference";
22
import { whoAmI } from "@huggingface/hub";
33

44
const hfToken = process.env.token;
55

6-
const hf = new HfInference(hfToken);
6+
const hf = new InferenceClient(hfToken);
77

88
(async () => {
99
const info = await whoAmI({ credentials: { accessToken: "hf_hub.js" }, hubUrl: "https://hub-ci.huggingface.co" });

packages/agents/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const agent = new HfAgent(
5858

5959

6060
#### From your own endpoints
61-
You can also specify your own endpoint, as long as it implements the same API, for exemple using [text generation inference](https://github.com/huggingface/text-generation-inference) and [Inference Endpoints](https://huggingface.co/inference-endpoints).
61+
You can also specify your own endpoint, as long as it implements the same API, for example using [text generation inference](https://github.com/huggingface/text-generation-inference) and [Inference Endpoints](https://huggingface.co/inference-endpoints).
6262

6363
```ts
6464
import { HfAgent, LLMFromEndpoint } from "@huggingface/agents";

packages/agents/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@
5656
"@types/node": "^18.13.0"
5757
},
5858
"dependencies": {
59-
"@huggingface/inference": "^2.6.1"
59+
"@huggingface/inference": "workspace:^"
6060
}
6161
}

packages/agents/pnpm-lock.yaml

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)