Skip to content

Commit 1b0664d

Browse files
author
Fabien Ric
committed
Merge remote-tracking branch 'hf/main' into ovhcloud-inference-provider
2 parents 31c666f + 905181b commit 1b0664d

Some content is hidden

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

62 files changed

+2132
-7799
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: MCP Client - Version and Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
newversion:
7+
type: choice
8+
description: "Semantic Version Bump Type"
9+
default: patch
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
concurrency:
16+
group: "push-to-main"
17+
18+
defaults:
19+
run:
20+
working-directory: packages/mcp-client
21+
22+
jobs:
23+
version_and_release:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
with:
28+
token: ${{ secrets.BOT_ACCESS_TOKEN }}
29+
- run: npm install -g corepack@latest && corepack enable
30+
- uses: actions/setup-node@v3
31+
with:
32+
node-version: "20"
33+
cache: "pnpm"
34+
cache-dependency-path: |
35+
packages/mcp-client/pnpm-lock.yaml
36+
packages/doc-internal/pnpm-lock.yaml
37+
registry-url: "https://registry.npmjs.org"
38+
- run: pnpm install
39+
- run: git config --global user.name machineuser
40+
- run: git config --global user.email [email protected]
41+
- run: |
42+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
43+
BUMPED_VERSION=$(node -p "require('semver').inc('$PACKAGE_VERSION', '${{ github.event.inputs.newversion }}')")
44+
# Update package.json with the new version
45+
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
46+
pnpm --filter doc-internal run fix-cdn-versions
47+
git add ../..
48+
git commit -m "🔖 @huggingface/mcp-client $BUMPED_VERSION"
49+
git tag "mcp-client-v$BUMPED_VERSION"
50+
51+
# Add checks for dependencies if needed, similar to hub-publish.yml
52+
- name: "Check Deps are published before publishing this package"
53+
run: pnpm -w check-deps inference && pnpm -w check-deps tasks
54+
55+
- run: pnpm publish --no-git-checks .
56+
env:
57+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
58+
- run: git pull --rebase && git push --follow-tags
59+
# hack - reuse actions/setup-node@v3 just to set a new registry
60+
- uses: actions/setup-node@v3
61+
with:
62+
node-version: "20"
63+
registry-url: "https://npm.pkg.github.com"
64+
# Disable for now, until github supports PATs for writing github packages (https://github.com/github/roadmap/issues/558)
65+
# - run: pnpm publish --no-git-checks .
66+
# env:
67+
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
- name: "Update Doc"
69+
uses: peter-evans/repository-dispatch@v2
70+
with:
71+
event-type: doc-build
72+
token: ${{ secrets.BOT_ACCESS_TOKEN }}

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
pnpm --filter ...[${{ steps.since.outputs.SINCE }}]... build
3939
4040
- name: Test
41-
run: VCR_MODE=playback pnpm --filter ...[${{ steps.since.outputs.SINCE }}] test
41+
run: pnpm --filter ...[${{ steps.since.outputs.SINCE }}] test
4242
env:
4343
HF_TOKEN: ${{ secrets.HF_TOKEN }}
4444

@@ -76,7 +76,7 @@ jobs:
7676
pnpm --filter ...[${{ steps.since.outputs.SINCE }}]... build
7777
7878
- name: Test in browser
79-
run: VCR_MODE=playback pnpm --filter ...[${{ steps.since.outputs.SINCE }}] test:browser
79+
run: pnpm --filter ...[${{ steps.since.outputs.SINCE }}] test:browser
8080
env:
8181
HF_TOKEN: ${{ secrets.HF_TOKEN }}
8282

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/inference@3.8.1/+esm';
100+
import { InferenceClient } from 'https://cdn.jsdelivr.net/npm/@huggingface/inference@3.9.2/+esm';
101101
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm";
102102
</script>
103103
```

docs/_toctree.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
title: Interact with the Hub
1515
- local: hub/modules
1616
title: API Reference
17+
- title: "@huggingface/mcp-client"
18+
isExpanded: true
19+
sections:
20+
- local: mcp-client/README
21+
title: Simple MCP Client and smol Agent built on top of Inference Client
1722
- title: "@huggingface/agent"
1823
isExpanded: true
1924
sections:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"check-deps": "tsx scripts/check-deps.ts"
1212
},
1313
"devDependencies": {
14+
"@types/node": "^22.14.1",
1415
"@typescript-eslint/eslint-plugin": "^7.2.0",
1516
"@typescript-eslint/parser": "^7.2.0",
16-
"@types/node": "^18.16.1",
1717
"@vitest/browser": "^0.34.6",
1818
"eslint": "^8.57.0",
1919
"eslint-config-prettier": "^9.0.0",

packages/doc-internal/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Package to generate doc for other @huggingface packages",
66
"private": true,
77
"scripts": {
8-
"start": "pnpm run fix-cdn-versions && pnpm run doc-hub && pnpm run doc-inference && pnpm run doc-agents && pnpm run doc-space-header && pnpm run doc-gguf && cp ../../README.md ../../docs/index.md && pnpm run update-toc && pnpm run fix-md-links && pnpm run fix-md-headinghashlinks",
8+
"start": "pnpm run fix-cdn-versions && pnpm run doc-hub && pnpm run doc-inference && pnpm run doc-agents && pnpm run doc-space-header && pnpm run doc-gguf && pnpm run doc-mcp-client && cp ../../README.md ../../docs/index.md && pnpm run update-toc && pnpm run fix-md-links && pnpm run fix-md-headinghashlinks",
99
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
1010
"lint:check": "eslint --ext .cjs,.ts .",
1111
"format": "prettier --write .",
@@ -14,6 +14,7 @@
1414
"doc-inference": "typedoc --tsconfig ../inference/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/inference --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../inference/src/index.ts",
1515
"doc-agents": "typedoc --tsconfig ../agents/tsconfig.json --githubPages false --plugin typedoc-plugin-markdown --out ../../docs/agents --hideBreadcrumbs --hideInPageTOC --sourceLinkTemplate https://github.com/huggingface/huggingface.js/blob/main/{path}#L{line} ../agents/src/index.ts",
1616
"doc-gguf": "mkdir -p ../../docs/gguf && cp ../../packages/gguf/README.md ../../docs/gguf/README.md",
17+
"doc-mcp-client": "mkdir -p ../../docs/mcp-client && cp ../../packages/mcp-client/README.md ../../docs/mcp-client/README.md",
1718
"doc-space-header": "mkdir -p ../../docs/space-header && cp ../../packages/space-header/README.md ../../docs/space-header/README.md",
1819
"update-toc": "tsx update-toc.ts",
1920
"fix-cdn-versions": "tsx fix-cdn-versions.ts",

packages/inference/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,20 @@ You can send inference requests to third-party providers with the inference clie
4848

4949
Currently, we support the following providers:
5050
- [Fal.ai](https://fal.ai)
51+
- [Featherless AI](https://featherless.ai)
5152
- [Fireworks AI](https://fireworks.ai)
5253
- [Hyperbolic](https://hyperbolic.xyz)
5354
- [Nebius](https://studio.nebius.ai)
5455
- [Novita](https://novita.ai/?utm_source=github_huggingface&utm_medium=github_readme&utm_campaign=link)
56+
- [Nscale](https://nscale.com)
57+
- [OVHcloud](https://endpoints.ai.cloud.ovh.net/)
5558
- [Replicate](https://replicate.com)
5659
- [Sambanova](https://sambanova.ai)
5760
- [Together](https://together.xyz)
5861
- [Blackforestlabs](https://blackforestlabs.ai)
5962
- [Cohere](https://cohere.com)
6063
- [Cerebras](https://cerebras.ai/)
61-
- [OVHcloud](https://endpoints.ai.cloud.ovh.net/)
64+
- [Groq](https://groq.com)
6265

6366
To send requests to a third-party provider, you have to pass the `provider` parameter to the inference function. Make sure your request is authenticated with an access token.
6467
```ts
@@ -77,15 +80,18 @@ When authenticated with a third-party provider key, the request is made directly
7780

7881
Only a subset of models are supported when requesting third-party providers. You can check the list of supported models per pipeline tasks here:
7982
- [Fal.ai supported models](https://huggingface.co/api/partners/fal-ai/models)
83+
- [Featherless AI supported models](https://huggingface.co/api/partners/featherless-ai/models)
8084
- [Fireworks AI supported models](https://huggingface.co/api/partners/fireworks-ai/models)
8185
- [Hyperbolic supported models](https://huggingface.co/api/partners/hyperbolic/models)
8286
- [Nebius supported models](https://huggingface.co/api/partners/nebius/models)
87+
- [Nscale supported models](https://huggingface.co/api/partners/nscale/models)
88+
- [OVHcloud supported models](https://huggingface.co/api/partners/ovhcloud/models)
8389
- [Replicate supported models](https://huggingface.co/api/partners/replicate/models)
8490
- [Sambanova supported models](https://huggingface.co/api/partners/sambanova/models)
8591
- [Together supported models](https://huggingface.co/api/partners/together/models)
8692
- [Cohere supported models](https://huggingface.co/api/partners/cohere/models)
8793
- [Cerebras supported models](https://huggingface.co/api/partners/cerebras/models)
88-
- [OVHcloud supported models](https://huggingface.co/api/partners/ovhcloud/models)
94+
- [Groq supported models](https://console.groq.com/docs/models)
8995
- [HF Inference API (serverless)](https://huggingface.co/models?inference=warm&sort=trending)
9096

9197
**Important note:** To be compatible, the third-party API must adhere to the "standard" shape API we expect on HF model pages for each pipeline task type.

packages/inference/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huggingface/inference",
3-
"version": "3.8.1",
3+
"version": "3.9.2",
44
"packageManager": "[email protected]",
55
"license": "MIT",
66
"author": "Hugging Face and Tim Mikeladze <[email protected]>",

packages/inference/src/lib/getInferenceProviderMapping.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { typedInclude } from "../utils/typedInclude";
88
export const inferenceProviderMappingCache = new Map<ModelId, InferenceProviderMapping>();
99

1010
export type InferenceProviderMapping = Partial<
11-
Record<InferenceProvider, Omit<InferenceProviderModelMapping, "hfModelId" | "adapterWeightsPath">>
11+
Record<InferenceProvider, Omit<InferenceProviderModelMapping, "hfModelId">>
1212
>;
1313

1414
export interface InferenceProviderModelMapping {
@@ -74,22 +74,6 @@ export async function getInferenceProviderMapping(
7474
`Model ${params.modelId} is in staging mode for provider ${params.provider}. Meant for test purposes only.`
7575
);
7676
}
77-
if (providerMapping.adapter === "lora") {
78-
const treeResp = await (options?.fetch ?? fetch)(`${HF_HUB_URL}/api/models/${params.modelId}/tree/main`);
79-
if (!treeResp.ok) {
80-
throw new Error(`Unable to fetch the model tree for ${params.modelId}.`);
81-
}
82-
const tree: Array<{ type: "file" | "directory"; path: string }> = await treeResp.json();
83-
const adapterWeightsPath = tree.find(({ type, path }) => type === "file" && path.endsWith(".safetensors"))?.path;
84-
if (!adapterWeightsPath) {
85-
throw new Error(`No .safetensors file found in the model tree for ${params.modelId}.`);
86-
}
87-
return {
88-
...providerMapping,
89-
hfModelId: params.modelId,
90-
adapterWeightsPath,
91-
};
92-
}
9377
return { ...providerMapping, hfModelId: params.modelId };
9478
}
9579
return null;

packages/inference/src/lib/getProviderHelper.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import * as BlackForestLabs from "../providers/black-forest-labs";
22
import * as Cerebras from "../providers/cerebras";
33
import * as Cohere from "../providers/cohere";
44
import * as FalAI from "../providers/fal-ai";
5+
import * as FeatherlessAI from "../providers/featherless-ai";
56
import * as Fireworks from "../providers/fireworks-ai";
7+
import * as Groq from "../providers/groq";
68
import * as HFInference from "../providers/hf-inference";
7-
89
import * as Hyperbolic from "../providers/hyperbolic";
910
import * as Nebius from "../providers/nebius";
1011
import * as Novita from "../providers/novita";
12+
import * as Nscale from "../providers/nscale";
1113
import * as OpenAI from "../providers/openai";
1214
import * as OvhCloud from "../providers/ovhcloud";
1315
import type {
@@ -63,6 +65,10 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
6365
"text-to-video": new FalAI.FalAITextToVideoTask(),
6466
"automatic-speech-recognition": new FalAI.FalAIAutomaticSpeechRecognitionTask(),
6567
},
68+
"featherless-ai": {
69+
conversational: new FeatherlessAI.FeatherlessAIConversationalTask(),
70+
"text-generation": new FeatherlessAI.FeatherlessAITextGenerationTask(),
71+
},
6672
"hf-inference": {
6773
"text-to-image": new HFInference.HFInferenceTextToImageTask(),
6874
conversational: new HFInference.HFInferenceConversationalTask(),
@@ -96,6 +102,10 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
96102
"fireworks-ai": {
97103
conversational: new Fireworks.FireworksConversationalTask(),
98104
},
105+
groq: {
106+
conversational: new Groq.GroqConversationalTask(),
107+
"text-generation": new Groq.GroqTextGenerationTask(),
108+
},
99109
hyperbolic: {
100110
"text-to-image": new Hyperbolic.HyperbolicTextToImageTask(),
101111
conversational: new Hyperbolic.HyperbolicConversationalTask(),
@@ -110,6 +120,10 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
110120
conversational: new Novita.NovitaConversationalTask(),
111121
"text-generation": new Novita.NovitaTextGenerationTask(),
112122
},
123+
nscale: {
124+
"text-to-image": new Nscale.NscaleTextToImageTask(),
125+
conversational: new Nscale.NscaleConversationalTask(),
126+
},
113127
openai: {
114128
conversational: new OpenAI.OpenAIConversationalTask(),
115129
},

0 commit comments

Comments
 (0)