diff --git a/README.md b/README.md index fc8eb44a35..f2e4a4750c 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ await uploadFile({ await inference.chatCompletion({ model: "meta-llama/Llama-3.1-8B-Instruct", + provider: "sambanova", // or together, fal-ai, replicate, cohere … messages: [ { role: "user", @@ -39,11 +40,11 @@ await inference.chatCompletion({ ], max_tokens: 512, temperature: 0.5, - provider: "sambanova", // or together, fal-ai, replicate, cohere … }); await inference.textToImage({ model: "black-forest-labs/FLUX.1-dev", + provider: "replicate", inputs: "a picture of a green bird", }); @@ -54,7 +55,7 @@ await inference.textToImage({ This is a collection of JS libraries to interact with the Hugging Face API, with TS types included. -- [@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 +- [@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 - [@huggingface/hub](packages/hub/README.md): Interact with huggingface.co to create or delete repos and commit / download files - [@huggingface/agents](packages/agents/README.md): Interact with HF models through a natural language interface - [@huggingface/gguf](packages/gguf/README.md): A GGUF parser that works on remotely hosted files. @@ -84,7 +85,7 @@ npm install @huggingface/agents Then import the libraries in your code: ```ts -import { HfInference } from "@huggingface/inference"; +import { InferenceClient } from "@huggingface/inference"; import { HfAgent } from "@huggingface/agents"; import { createRepo, commit, deleteRepo, listFiles } from "@huggingface/hub"; import type { RepoId } from "@huggingface/hub"; @@ -96,7 +97,7 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or ```html ``` @@ -105,12 +106,12 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or ```ts // esm.sh -import { HfInference } from "https://esm.sh/@huggingface/inference" +import { InferenceClient } from "https://esm.sh/@huggingface/inference" import { HfAgent } from "https://esm.sh/@huggingface/agents"; import { createRepo, commit, deleteRepo, listFiles } from "https://esm.sh/@huggingface/hub" // or npm: -import { HfInference } from "npm:@huggingface/inference" +import { InferenceClient } from "npm:@huggingface/inference" import { HfAgent } from "npm:@huggingface/agents"; 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 ### @huggingface/inference examples ```ts -import { HfInference } from "@huggingface/inference"; +import { InferenceClient } from "@huggingface/inference"; const HF_TOKEN = "hf_..."; -const inference = new HfInference(HF_TOKEN); +const inference = new InferenceClient(HF_TOKEN); // Chat completion API const out = await inference.chatCompletion({ @@ -179,7 +180,7 @@ await inference.imageToText({ // Using your own dedicated inference endpoint: https://hf.co/docs/inference-endpoints/ const gpt2 = inference.endpoint('https://xyz.eu-west-1.aws.endpoints.huggingface.cloud/gpt2'); -const { generated_text } = await gpt2.textGeneration({inputs: 'The answer to the universe is'}); +const { generated_text } = await gpt2.textGeneration({ inputs: 'The answer to the universe is' }); // Chat Completion const llamaEndpoint = inference.endpoint( diff --git a/e2e/deno/index.ts b/e2e/deno/index.ts index bd70f4e418..02d11fe249 100644 --- a/e2e/deno/index.ts +++ b/e2e/deno/index.ts @@ -1,4 +1,4 @@ -import { HfInference } from "npm:@huggingface/inference@*"; +import { InferenceClient } from "npm:@huggingface/inference@*"; import { whoAmI, listFiles } from "npm:@huggingface/hub@*"; 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" })) { const token = Deno.env.get("HF_TOKEN"); if (token) { - const hf = new HfInference(token); + const hf = new InferenceClient(token); const tokenInfo = await whoAmI({ credentials: { accessToken: token } }); console.log(tokenInfo); diff --git a/e2e/svelte/src/routes/+page.svelte b/e2e/svelte/src/routes/+page.svelte index 1ca0727d28..5c36447d5e 100644 --- a/e2e/svelte/src/routes/+page.svelte +++ b/e2e/svelte/src/routes/+page.svelte @@ -1,8 +1,8 @@