Skip to content

Export InferenceProviderMappingEntry from types.ts #1540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions packages/inference/src/lib/getInferenceProviderMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ import type { WidgetType } from "@huggingface/tasks";
import { HF_HUB_URL } from "../config.js";
import { HARDCODED_MODEL_INFERENCE_MAPPING } from "../providers/consts.js";
import { EQUIVALENT_SENTENCE_TRANSFORMERS_TASKS } from "../providers/hf-inference.js";
import type { InferenceProvider, InferenceProviderOrPolicy, ModelId } from "../types.js";
import type { InferenceProvider, InferenceProviderMappingEntry, InferenceProviderOrPolicy, ModelId } from "../types.js";
import { typedInclude } from "../utils/typedInclude.js";
import { InferenceClientHubApiError, InferenceClientInputError } from "../errors.js";

export const inferenceProviderMappingCache = new Map<ModelId, InferenceProviderMappingEntry[]>();

export interface InferenceProviderMappingEntry {
adapter?: string;
adapterWeightsPath?: string;
hfModelId: ModelId;
provider: string;
providerId: string;
status: "live" | "staging";
task: WidgetType;
type?: "single-model" | "tag-filter";
}

/**
* Normalize inferenceProviderMapping to always return an array format.
* This provides backward and forward compatibility for the API changes.
Expand Down
3 changes: 1 addition & 2 deletions packages/inference/src/lib/makeRequestOptions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HF_HEADER_X_BILL_TO, HF_HUB_URL } from "../config.js";
import { PACKAGE_NAME, PACKAGE_VERSION } from "../package.js";
import type { InferenceTask, Options, RequestArgs } from "../types.js";
import type { InferenceProviderMappingEntry } from "./getInferenceProviderMapping.js";
import type { InferenceTask, InferenceProviderMappingEntry, Options, RequestArgs } from "../types.js";
import { getInferenceProviderMapping } from "./getInferenceProviderMapping.js";
import type { getProviderHelper } from "./getProviderHelper.js";
import { isUrl } from "./isUrl.js";
Expand Down
3 changes: 1 addition & 2 deletions packages/inference/src/providers/consts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { InferenceProviderMappingEntry } from "../lib/getInferenceProviderMapping.js";
import type { InferenceProvider } from "../types.js";
import type { InferenceProvider, InferenceProviderMappingEntry } from "../types.js";
import { type ModelId } from "../types.js";

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/inference/src/snippets/getInferenceSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import {
} from "@huggingface/tasks";
import type { PipelineType, WidgetType } from "@huggingface/tasks";
import type { ChatCompletionInputMessage, GenerationParameters } from "@huggingface/tasks";
import type { InferenceProviderMappingEntry } from "../lib/getInferenceProviderMapping.js";
import { getProviderHelper } from "../lib/getProviderHelper.js";
import { makeRequestOptionsFromResolvedModel } from "../lib/makeRequestOptions.js";
import type { InferenceProviderOrPolicy, InferenceTask, RequestArgs } from "../types.js";
import type { InferenceProviderMappingEntry, InferenceProviderOrPolicy, InferenceTask, RequestArgs } from "../types.js";
import { templates } from "./templates.exported.js";

export type InferenceSnippetOptions = {
Expand Down
14 changes: 12 additions & 2 deletions packages/inference/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ChatCompletionInput, PipelineType } from "@huggingface/tasks";
import type { InferenceProviderMappingEntry } from "./lib/getInferenceProviderMapping.js";
import type { ChatCompletionInput, PipelineType, WidgetType } from "@huggingface/tasks";

/**
* HF model id, like "meta-llama/Llama-3.3-70B-Instruct"
Expand Down Expand Up @@ -63,6 +62,17 @@ export type InferenceProvider = (typeof INFERENCE_PROVIDERS)[number];

export type InferenceProviderOrPolicy = (typeof PROVIDERS_OR_POLICIES)[number];

export interface InferenceProviderMappingEntry {
adapter?: string;
adapterWeightsPath?: string;
hfModelId: ModelId;
provider: string;
providerId: string;
status: "live" | "staging";
task: WidgetType;
type?: "single-model" | "tag-filter";
}

export interface BaseArgs {
/**
* The access token to use. Without it, you'll get rate-limited quickly.
Expand Down