Skip to content

feat(inference): Add BagelNet inference provider support #1574

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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 @@ -47,6 +47,7 @@ Your access token should be kept private. If you need to protect it in front-end
You can send inference requests to third-party providers with the inference client.

Currently, we support the following providers:
- [BagelNet](https://bagel.net)
- [Fal.ai](https://fal.ai)
- [Featherless AI](https://featherless.ai)
- [Fireworks AI](https://fireworks.ai)
Expand Down Expand Up @@ -82,6 +83,7 @@ When authenticated with a Hugging Face access token, the request is routed throu
When authenticated with a third-party provider key, the request is made directly against that provider's inference API.

Only a subset of models are supported when requesting third-party providers. You can check the list of supported models per pipeline tasks here:
- [BagelNet supported models](https://huggingface.co/api/partners/bagelnet/models)
- [Fal.ai supported models](https://huggingface.co/api/partners/fal-ai/models)
- [Featherless AI supported models](https://huggingface.co/api/partners/featherless-ai/models)
- [Fireworks AI supported models](https://huggingface.co/api/partners/fireworks-ai/models)
Expand Down
4 changes: 4 additions & 0 deletions packages/inference/src/lib/getProviderHelper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as BagelNet from "../providers/bagelnet.js";
import * as BlackForestLabs from "../providers/black-forest-labs.js";
import * as Cerebras from "../providers/cerebras.js";
import * as Cohere from "../providers/cohere.js";
Expand Down Expand Up @@ -52,6 +53,9 @@ import type { InferenceProvider, InferenceProviderOrPolicy, InferenceTask } from
import { InferenceClientInputError } from "../errors.js";

export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask, TaskProviderHelper>>> = {
bagelnet: {
conversational: new BagelNet.BagelNetConversational(),
},
"black-forest-labs": {
"text-to-image": new BlackForestLabs.BlackForestLabsTextToImageTask(),
},
Expand Down
25 changes: 25 additions & 0 deletions packages/inference/src/providers/bagelnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { BaseConversationalTask } from "./providerHelper.js";

export class BagelNetConversational extends BaseConversationalTask {
constructor() {
super("bagelnet", "https://api.bagel.net", false);
}

override makeRoute(): string {
return "/v1/chat/completions";
}

override preparePayload(params: any) {
return {
model: params.model,
messages: params.messages,
max_tokens: params.max_tokens,
temperature: params.temperature,
stream: params.stream ?? false,
};
}

override getResponse(r: any) {
return r;
}
}
1 change: 1 addition & 0 deletions packages/inference/src/providers/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
* Example:
* "Qwen/Qwen2.5-Coder-32B-Instruct": "Qwen2.5-Coder-32B-Instruct",
*/
bagelnet: {},
"black-forest-labs": {},
cerebras: {},
cohere: {},
Expand Down
1 change: 1 addition & 0 deletions packages/inference/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface Options {
export type InferenceTask = Exclude<PipelineType, "other"> | "conversational";

export const INFERENCE_PROVIDERS = [
"bagelnet",
"black-forest-labs",
"cerebras",
"cohere",
Expand Down