diff --git a/packages/inference/README.md b/packages/inference/README.md index 664c224583..59d436a28f 100644 --- a/packages/inference/README.md +++ b/packages/inference/README.md @@ -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. @@ -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! diff --git a/packages/inference/src/lib/getProviderHelper.ts b/packages/inference/src/lib/getProviderHelper.ts index e18a258a0f..2a678f0511 100644 --- a/packages/inference/src/lib/getProviderHelper.ts +++ b/packages/inference/src/lib/getProviderHelper.ts @@ -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"; @@ -183,6 +184,9 @@ export const PROVIDERS: Record 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 { + const headers = super.prepareHeaders(params, binary); + headers["x-source-channel"] = "hugging_face"; + headers["accept-language"] = "en-US,en"; + return headers; + } +} diff --git a/packages/inference/src/types.ts b/packages/inference/src/types.ts index e4165914d6..5f9c53b067 100644 --- a/packages/inference/src/types.ts +++ b/packages/inference/src/types.ts @@ -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; @@ -105,6 +106,7 @@ export const PROVIDERS_HUB_ORGS: Record = { together: "togethercomputer", wavespeed: "wavespeed", "zai-org": "zai-org", + zenmux: "zenmux", }; export interface InferenceProviderMappingEntry {