Skip to content
Open
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
2 changes: 2 additions & 0 deletions packages/inference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Currently, we support the following providers:
- [Groq](https://groq.com)
- [Wavespeed.ai](https://wavespeed.ai/)
- [Z.ai](https://z.ai/)
- [ZenMux](https://zenmux.ai)

To send requests to a third-party provider, you have to pass the `provider` parameter to the inference function. The default value of the `provider` parameter is "auto", which will select the first of the providers available for the model, sorted by your preferred order in https://hf.co/settings/inference-providers.

Expand Down Expand Up @@ -108,6 +109,7 @@ Only a subset of models are supported when requesting third-party providers. You
- [Novita AI supported models](https://huggingface.co/api/partners/novita/models)
- [Wavespeed.ai supported models](https://huggingface.co/api/partners/wavespeed/models)
- [Z.ai supported models](https://huggingface.co/api/partners/zai-org/models)
- [ZenMux supported models](https://huggingface.co/api/partners/zenmux/models)

❗**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.
This is not an issue for LLMs as everyone converged on the OpenAI API anyways, but can be more tricky for other tasks like "text-to-image" or "automatic-speech-recognition" where there exists no standard API. Let us know if any help is needed or if we can make things easier for you!
Expand Down
4 changes: 4 additions & 0 deletions packages/inference/src/lib/getProviderHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import * as Scaleway from "../providers/scaleway.js";
import * as Together from "../providers/together.js";
import * as Wavespeed from "../providers/wavespeed.js";
import * as Zai from "../providers/zai-org.js";
import * as Zenmux from "../providers/zenmux.js";
import type { InferenceProvider, InferenceProviderOrPolicy, InferenceTask } from "../types.js";
import { InferenceClientInputError } from "../errors.js";

Expand Down Expand Up @@ -183,6 +184,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
"zai-org": {
conversational: new Zai.ZaiConversationalTask(),
},
zenmux: {
conversational: new Zenmux.ZenmuxConversationalTask(),
},
};

/**
Expand Down
1 change: 1 addition & 0 deletions packages/inference/src/providers/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
together: {},
wavespeed: {},
"zai-org": {},
zenmux: {},
};
30 changes: 30 additions & 0 deletions packages/inference/src/providers/zenmux.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* See the registered mapping of HF model ID => ZenMux model ID here:
*
* https://huggingface.co/api/partners/zenmux/models
*
* This is a publicly available mapping.
*
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
*
* - If you work at ZenMux and want to update this mapping, please use the model mapping API we provide on huggingface.co
* - If you're a community member and want to add a new supported HF model to ZenMux, please open an issue on the present repo
* and we will tag ZenMux team members.
*
* Thanks!
*/
import { HeaderParams } from "../types.js";
import { BaseConversationalTask } from "./providerHelper.js";

export class ZenmuxConversationalTask extends BaseConversationalTask {
constructor() {
super("zenmux", "https://zenmux.ai/api/v1");
}
override prepareHeaders(params: HeaderParams, binary: boolean): Record<string, string> {
const headers = super.prepareHeaders(params, binary);
headers["x-source-channel"] = "hugging_face";
headers["accept-language"] = "en-US,en";
return headers;
}
}
2 changes: 2 additions & 0 deletions packages/inference/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const INFERENCE_PROVIDERS = [
"together",
"wavespeed",
"zai-org",
"zenmux",
] as const;

export const PROVIDERS_OR_POLICIES = [...INFERENCE_PROVIDERS, "auto"] as const;
Expand Down Expand Up @@ -105,6 +106,7 @@ export const PROVIDERS_HUB_ORGS: Record<InferenceProvider, string> = {
together: "togethercomputer",
wavespeed: "wavespeed",
"zai-org": "zai-org",
zenmux: "zenmux",
};

export interface InferenceProviderMappingEntry {
Expand Down