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 @@ -55,6 +55,7 @@ Currently, we support the following providers:
- [Nscale](https://nscale.com)
- [OVHcloud](https://endpoints.ai.cloud.ovh.net/)
- [Public AI](https://publicai.co)
- [Public AI (TEE)](https://publicai.io)
- [Replicate](https://replicate.com)
- [Scaleway](https://www.scaleway.com/en/generative-apis/)
- [Together](https://together.xyz)
Expand Down Expand Up @@ -90,6 +91,7 @@ Only a subset of models are supported when requesting third-party providers. You
- [HF Inference supported models](https://huggingface.co/api/partners/hf-inference/models)
- [Nscale supported models](https://huggingface.co/api/partners/nscale/models)
- [OVHcloud supported models](https://huggingface.co/api/partners/ovhcloud/models)
- [Public AI (TEE) supported models](https://huggingface.co/api/partners/publicai-tee/models)
- [Replicate supported models](https://huggingface.co/api/partners/replicate/models)
- [Scaleway supported models](https://huggingface.co/api/partners/scaleway/models)
- [Together supported models](https://huggingface.co/api/partners/together/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
Expand Up @@ -12,6 +12,7 @@ import * as Nscale from "../providers/nscale.js";
import * as OpenAI from "../providers/openai.js";
import * as OvhCloud from "../providers/ovhcloud.js";
import * as PublicAI from "../providers/publicai.js";
import * as PublicAITee from "../providers/publicai-tee.js";
import type {
AudioClassificationTaskHelper,
AudioToAudioTaskHelper,
Expand Down Expand Up @@ -143,6 +144,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
publicai: {
conversational: new PublicAI.PublicAIConversationalTask(),
},
"publicai-tee": {
conversational: new PublicAITee.PublicAITeeConversationalTask(),
},
replicate: {
"text-to-image": new Replicate.ReplicateTextToImageTask(),
"text-to-speech": new Replicate.ReplicateTextToSpeechTask(),
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 @@ -31,6 +31,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
nscale: {},
openai: {},
publicai: {},
"publicai-tee": {},
ovhcloud: {},
replicate: {},
scaleway: {},
Expand Down
7 changes: 7 additions & 0 deletions packages/inference/src/providers/publicai-tee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BaseConversationalTask } from "./providerHelper.js";

export class PublicAITeeConversationalTask extends BaseConversationalTask {
constructor() {
super("publicai-tee", "https://tee.publicai.io");
}
}
2 changes: 2 additions & 0 deletions packages/inference/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const INFERENCE_PROVIDERS = [
"openai",
"ovhcloud",
"publicai",
"publicai-tee",
"replicate",
"scaleway",
"together",
Expand Down Expand Up @@ -92,6 +93,7 @@ export const PROVIDERS_HUB_ORGS: Record<InferenceProvider, string> = {
openai: "openai",
ovhcloud: "ovhcloud",
publicai: "publicai",
"publicai-tee": "publicai-tee",
replicate: "replicate",
scaleway: "scaleway",
together: "togethercomputer",
Expand Down
53 changes: 53 additions & 0 deletions packages/inference/test/InferenceClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,59 @@ describe.skip("InferenceClient", () => {
TIMEOUT,
);

describe.concurrent(
"PublicAI TEE",
() => {
const client = new InferenceClient(env.HF_PUBLICAI_TEE_KEY ?? "dummy");

HARDCODED_MODEL_INFERENCE_MAPPING["publicai-tee"] = {
"MiniMaxAI/MiniMax-M2": {
provider: "publicai-tee",
hfModelId: "MiniMaxAI/MiniMax-M2",
providerId: "MiniMax-M2",
status: "live",
task: "conversational",
},
};

it("chatCompletion", async () => {
const res = await client.chatCompletion({
model: "MiniMaxAI/MiniMax-M2",
provider: "publicai-tee",
messages: [{ role: "user", content: "Complete this sentence with words, one plus one is equal " }],
});
if (res.choices && res.choices.length > 0) {
const completion = res.choices[0].message?.content;
expect(completion).toContain("two");
}
});

it("chatCompletion stream", async () => {
const stream = client.chatCompletionStream({
model: "MiniMaxAI/MiniMax-M2",
provider: "publicai-tee",
messages: [{ role: "user", content: "Say 'this is a test'" }],
stream: true,
}) as AsyncGenerator<ChatCompletionStreamOutput>;

let fullResponse = "";
for await (const chunk of stream) {
if (chunk.choices && chunk.choices.length > 0) {
const content = chunk.choices[0].delta?.content;
if (content) {
fullResponse += content;
}
}
}

// Verify we got a meaningful response
expect(fullResponse).toBeTruthy();
expect(fullResponse.length).toBeGreaterThan(0);
});
},
TIMEOUT,
);

describe.concurrent(
"Baseten",
() => {
Expand Down