Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SBrandeis committed Jan 15, 2025
1 parent 0bdd1f1 commit 1685163
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/inference/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const HF_HUB_URL = import.meta.env.HUGGINGFACE_HUB_URL ?? "https://huggingface.co";
export const HF_INFERENCE_API_URL = import.meta.env.HF_INFERENCE_API_URL ?? "https://api-inference.huggingface.co";
export const HF_HUB_URL = "https://huggingface.co";
export const HF_INFERENCE_API_URL = "https://api-inference.huggingface.co";
8 changes: 4 additions & 4 deletions packages/inference/src/lib/makeRequestOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { InferenceProvider } from "../types";
import type { InferenceTask, Options, RequestArgs } from "../types";
import { isUrl } from "./isUrl";

const HF_HUB_INFERENCE_PROXY_TEMPLATE = `{{HF_HUB_URL}}/inference-proxy/{{PROVIDER}}`;
const HF_HUB_INFERENCE_PROXY_TEMPLATE = `{{HF_HUB_URL}}/api/inference-proxy/{{PROVIDER}}`;

/**
* Lazy-loaded from huggingface.co/api/tasks when needed
Expand All @@ -34,7 +34,7 @@ export async function makeRequestOptions(
const { accessToken, endpointUrl, provider: maybeProvider, model: maybeModel, ...otherArgs } = args;
const provider = maybeProvider ?? "hf-inference";

const { forceTask, includeCredentials, taskHint, wait_for_model, use_cache, dont_load_model, chatCompletion } =
const { forceTask, includeCredentials, taskHint, wait_for_model, use_cache, dont_load_model, chatCompletion, hfHubUrl } =
options ?? {};

if (endpointUrl && provider !== "hf-inference") {
Expand Down Expand Up @@ -76,15 +76,15 @@ export async function makeRequestOptions(
authMethod,
chatCompletion: chatCompletion ?? false,
forceTask,
hfHubUrl: options?.hfHubUrl ?? HF_HUB_URL,
hfHubUrl: hfHubUrl ?? HF_HUB_URL,
model,
provider: provider ?? "hf-inference",
taskHint,
});

const headers: Record<string, string> = {};
if (accessToken) {
headers["Authorization"] = provider === "fal-ai" ? `Key ${accessToken}` : `Bearer ${accessToken}`;
headers["Authorization"] = provider === "fal-ai" && authMethod === "provider-key" ? `Key ${accessToken}` : `Bearer ${accessToken}`;
}

const binary = "data" in args && !!args.data;
Expand Down
2 changes: 1 addition & 1 deletion packages/inference/test/vcr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { omit } from "../src/utils/omit";
import { HF_HUB_URL } from "../src/lib/getDefaultTask";
import { HF_HUB_URL } from "../src/config";
import { isBackend } from "../src/utils/isBackend";
import { isFrontend } from "../src/utils/isFrontend";

Expand Down

0 comments on commit 1685163

Please sign in to comment.