Skip to content

Commit f5b2e79

Browse files
authored
Merge branch 'main' into feat/novita-wan-t2v
2 parents c55128a + 2a5443f commit f5b2e79

File tree

70 files changed

+733
-623
lines changed

Some content is hidden

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

70 files changed

+733
-623
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
run: |
106106
sleep 3
107107
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/
108+
pnpm --filter inference --filter hub --filter tasks --filter jinja publish --force --no-git-checks --registry http://localhost:4874/
109109
110110
- name: E2E test - test yarn install
111111
working-directory: e2e/ts
@@ -136,7 +136,7 @@ jobs:
136136
deno-version: vx.x.x
137137
- name: E2E test - deno import from npm
138138
working-directory: e2e/deno
139-
run: deno run --allow-net --allow-env=HF_TOKEN index.ts
139+
run: deno run --allow-read --allow-net --allow-env=HF_TOKEN index.ts
140140
env:
141141
NPM_CONFIG_REGISTRY: http://localhost:4874/
142142
HF_TOKEN: ${{ secrets.HF_TOKEN }}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"search.exclude": {
1818
"**/dist": true
1919
},
20-
"typescript.tsdk": "node_modules/typescript/lib"
20+
"typescript.tsdk": "node_modules/typescript/lib",
2121
}

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

9898
```html
9999
<script type="module">
100-
import { InferenceClient } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected].1/+esm';
100+
import { InferenceClient } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected].2/+esm';
101101
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm";
102102
</script>
103103
```

packages/inference/package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huggingface/inference",
3-
"version": "3.5.1",
3+
"version": "3.5.2",
44
"packageManager": "[email protected]",
55
"license": "MIT",
66
"author": "Hugging Face and Tim Mikeladze <[email protected]>",
@@ -33,9 +33,16 @@
3333
"main": "./dist/index.cjs",
3434
"module": "./dist/index.js",
3535
"exports": {
36-
"types": "./dist/src/index.d.ts",
37-
"require": "./dist/index.cjs",
38-
"import": "./dist/index.js"
36+
".": {
37+
"types": "./dist/src/index.d.ts",
38+
"require": "./dist/index.cjs",
39+
"import": "./dist/index.js"
40+
}
41+
},
42+
"browser": {
43+
"./src/snippets/index.js": false,
44+
"./dist/index.js": "./dist/browser/index.js",
45+
"./dist/index.mjs": "./dist/browser/index.mjs"
3946
},
4047
"type": "module",
4148
"scripts": {
@@ -52,7 +59,8 @@
5259
"check": "tsc"
5360
},
5461
"dependencies": {
55-
"@huggingface/tasks": "workspace:^"
62+
"@huggingface/tasks": "workspace:^",
63+
"@huggingface/jinja": "workspace:^"
5664
},
5765
"devDependencies": {
5866
"@types/node": "18.13.0"

packages/inference/pnpm-lock.yaml

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

packages/inference/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export { InferenceClient, InferenceClientEndpoint, HfInference } from "./Inferen
22
export { InferenceOutputError } from "./lib/InferenceOutputError";
33
export * from "./types";
44
export * from "./tasks";
5-
65
import * as snippets from "./snippets/index.js";
6+
77
export { snippets };

packages/inference/src/lib/makeRequestOptions.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ export async function makeRequestOptions(
5656
/** In most cases (unless we pass a endpointUrl) we know the task */
5757
task?: InferenceTask;
5858
chatCompletion?: boolean;
59+
/* Used internally to generate inference snippets (in which case model mapping is done separately) */
60+
skipModelIdResolution?: boolean;
5961
}
6062
): Promise<{ url: string; info: RequestInit }> {
6163
const { accessToken, endpointUrl, provider: maybeProvider, model: maybeModel, ...remainingArgs } = args;
6264
const provider = maybeProvider ?? "hf-inference";
6365
const providerConfig = providerConfigs[provider];
6466

65-
const { includeCredentials, task, chatCompletion, signal } = options ?? {};
67+
const { includeCredentials, task, chatCompletion, signal, skipModelIdResolution } = options ?? {};
6668

6769
if (endpointUrl && provider !== "hf-inference") {
6870
throw new Error(`Cannot use endpointUrl with a third-party provider.`);
@@ -81,15 +83,17 @@ export async function makeRequestOptions(
8183
}
8284
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8385
const hfModel = maybeModel ?? (await loadDefaultModel(task!));
84-
const model = providerConfig.clientSideRoutingOnly
85-
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
86-
removeProviderPrefix(maybeModel!, provider)
87-
: // For closed-models API providers, one needs to pass the model ID directly (e.g. "gpt-3.5-turbo")
88-
await getProviderModelId({ model: hfModel, provider }, args, {
89-
task,
90-
chatCompletion,
91-
fetch: options?.fetch,
92-
});
86+
const model = skipModelIdResolution
87+
? hfModel
88+
: providerConfig.clientSideRoutingOnly
89+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
90+
removeProviderPrefix(maybeModel!, provider)
91+
: // For closed-models API providers, one needs to pass the model ID directly (e.g. "gpt-3.5-turbo")
92+
await getProviderModelId({ model: hfModel, provider }, args, {
93+
task,
94+
chatCompletion,
95+
fetch: options?.fetch,
96+
});
9397

9498
const authMethod = (() => {
9599
if (providerConfig.clientSideRoutingOnly) {

0 commit comments

Comments
 (0)