Skip to content

Commit a2d4a92

Browse files
committed
Revert "Switch path to router.huggingface.co (#1188)"
This reverts commit 658e1b9.
1 parent d803666 commit a2d4a92

File tree

6 files changed

+188
-190
lines changed

6 files changed

+188
-190
lines changed

packages/inference/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ for await (const output of hf.textGenerationStream({
125125

126126
### Text Generation (Chat Completion API Compatible)
127127

128-
Using the `chatCompletion` method, you can generate text with models compatible with the OpenAI Chat Completion API. All models served by [TGI](https://huggingface.co/docs/text-generation-inference/) on Hugging Face support Messages API.
128+
Using the `chatCompletion` method, you can generate text with models compatible with the OpenAI Chat Completion API. All models served by [TGI](https://api-inference.huggingface.co/framework/text-generation-inference) on Hugging Face support Messages API.
129129

130130
[Demo](https://huggingface.co/spaces/huggingfacejs/streaming-chat-completion)
131131

packages/inference/src/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export const HF_HUB_URL = "https://huggingface.co";
2-
export const HF_ROUTER_URL = "https://router.huggingface.co";

packages/inference/src/lib/makeRequestOptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HF_HUB_URL, HF_ROUTER_URL } from "../config";
1+
import { HF_HUB_URL } from "../config";
22
import { FAL_AI_API_BASE_URL } from "../providers/fal-ai";
33
import { NEBIUS_API_BASE_URL } from "../providers/nebius";
44
import { REPLICATE_API_BASE_URL } from "../providers/replicate";
@@ -11,7 +11,7 @@ import { isUrl } from "./isUrl";
1111
import { version as packageVersion, name as packageName } from "../../package.json";
1212
import { getProviderModelId } from "./getProviderModelId";
1313

14-
const HF_HUB_INFERENCE_PROXY_TEMPLATE = `${HF_ROUTER_URL}/{{PROVIDER}}`;
14+
const HF_HUB_INFERENCE_PROXY_TEMPLATE = `${HF_HUB_URL}/api/inference-proxy/{{PROVIDER}}`;
1515

1616
/**
1717
* Lazy-loaded from huggingface.co/api/tasks when needed

packages/inference/test/HfInference.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ describe.concurrent("HfInference", () => {
2222
"HF Inference",
2323
() => {
2424
const hf = new HfInference(env.HF_TOKEN);
25-
2625
it("throws error if model does not exist", () => {
2726
expect(
2827
hf.fillMask({
29-
model: "this-model/does-not-exist-123",
28+
model: "this-model-does-not-exist-123",
3029
inputs: "[MASK] world!",
3130
})
32-
).rejects.toThrowError("Model this-model/does-not-exist-123 does not exist");
31+
).rejects.toThrowError("Not Found: Model not found");
3332
});
3433

3534
it("fillMask", async () => {
@@ -649,7 +648,7 @@ describe.concurrent("HfInference", () => {
649648
});
650649

651650
it("endpoint - makes request to specified endpoint", async () => {
652-
const ep = hf.endpoint("https://router.huggingface.co/hf-inference/models/openai-community/gpt2");
651+
const ep = hf.endpoint("https://api-inference.huggingface.co/models/openai-community/gpt2");
653652
const { generated_text } = await ep.textGeneration({
654653
inputs: "one plus two equals",
655654
});
@@ -687,7 +686,7 @@ describe.concurrent("HfInference", () => {
687686
expect(out).toContain("2");
688687
});
689688

690-
it.skip("chatCompletionStream modelId Fail - OpenAI Specs", async () => {
689+
it("chatCompletionStream modelId Fail - OpenAI Specs", async () => {
691690
expect(
692691
hf
693692
.chatCompletionStream({
@@ -704,7 +703,7 @@ describe.concurrent("HfInference", () => {
704703
});
705704

706705
it("chatCompletion - OpenAI Specs", async () => {
707-
const ep = hf.endpoint("https://router.huggingface.co/hf-inference/models/mistralai/Mistral-7B-Instruct-v0.2");
706+
const ep = hf.endpoint("https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2");
708707
const res = await ep.chatCompletion({
709708
model: "tgi",
710709
messages: [{ role: "user", content: "Complete the this sentence with words one plus one is equal " }],
@@ -718,7 +717,7 @@ describe.concurrent("HfInference", () => {
718717
}
719718
});
720719
it("chatCompletionStream - OpenAI Specs", async () => {
721-
const ep = hf.endpoint("https://router.huggingface.co/hf-inference/models/mistralai/Mistral-7B-Instruct-v0.2");
720+
const ep = hf.endpoint("https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2");
722721
const stream = ep.chatCompletionStream({
723722
model: "tgi",
724723
messages: [{ role: "user", content: "Complete the equation 1+1= ,just the answer" }],

0 commit comments

Comments
 (0)