Skip to content

Commit cd12b8b

Browse files
committed
Add Phala inference provider
1 parent f8fdf6b commit cd12b8b

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

packages/inference/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Currently, we support the following providers:
5757
- [Nscale](https://nscale.com)
5858
- [NVIDIA](https://build.nvidia.com/)
5959
- [OVHcloud](https://endpoints.ai.cloud.ovh.net/)
60+
- [Phala](https://phala.com)
6061
- [Public AI](https://publicai.co)
6162
- [Replicate](https://replicate.com)
6263
- [Sambanova](https://sambanova.ai)
@@ -99,6 +100,7 @@ Only a subset of models are supported when requesting third-party providers. You
99100
- [Nscale supported models](https://huggingface.co/api/partners/nscale/models)
100101
- [NVIDIA supported models](https://huggingface.co/api/partners/nvidia/models)
101102
- [OVHcloud supported models](https://huggingface.co/api/partners/ovhcloud/models)
103+
- [Phala supported models](https://huggingface.co/api/partners/phala/models)
102104
- [Replicate supported models](https://huggingface.co/api/partners/replicate/models)
103105
- [Sambanova supported models](https://huggingface.co/api/partners/sambanova/models)
104106
- [Scaleway supported models](https://huggingface.co/api/partners/scaleway/models)

packages/inference/src/lib/getProviderHelper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as Nscale from "../providers/nscale.js";
1616
import * as Nvidia from "../providers/nvidia.js";
1717
import * as OpenAI from "../providers/openai.js";
1818
import * as OvhCloud from "../providers/ovhcloud.js";
19+
import * as Phala from "../providers/phala.js";
1920
import * as PublicAI from "../providers/publicai.js";
2021
import type {
2122
AudioClassificationTaskHelper,
@@ -163,6 +164,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
163164
conversational: new OvhCloud.OvhCloudConversationalTask(),
164165
"text-generation": new OvhCloud.OvhCloudTextGenerationTask(),
165166
},
167+
phala: {
168+
conversational: new Phala.PhalaConversationalTask(),
169+
},
166170
publicai: {
167171
conversational: new PublicAI.PublicAIConversationalTask(),
168172
},

packages/inference/src/providers/consts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
3737
openai: {},
3838
publicai: {},
3939
ovhcloud: {},
40+
phala: {},
4041
replicate: {},
4142
sambanova: {},
4243
scaleway: {},
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* See the registered mapping of HF model ID => Phala model ID here:
3+
*
4+
* https://huggingface.co/api/partners/phala/models
5+
*
6+
* This is a publicly available mapping.
7+
*
8+
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
9+
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
10+
*
11+
* - If you work at Phala and want to update this mapping, please use the model mapping API we provide on huggingface.co
12+
* - If you're a community member and want to add a new supported HF model to Phala, please open an issue on the present repo
13+
* and we will tag Phala team members.
14+
*
15+
* Thanks!
16+
*/
17+
18+
import { BaseConversationalTask } from "./providerHelper.js";
19+
20+
export class PhalaConversationalTask extends BaseConversationalTask {
21+
constructor() {
22+
super("phala", "https://api.redpill.ai");
23+
}
24+
}

packages/inference/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const INFERENCE_PROVIDERS = [
6363
"nvidia",
6464
"openai",
6565
"ovhcloud",
66+
"phala",
6667
"publicai",
6768
"replicate",
6869
"sambanova",
@@ -102,6 +103,7 @@ export const PROVIDERS_HUB_ORGS: Record<InferenceProvider, string> = {
102103
nvidia: "nvidia",
103104
openai: "openai",
104105
ovhcloud: "ovhcloud",
106+
phala: "PhalaCloud",
105107
publicai: "publicai",
106108
replicate: "replicate",
107109
sambanova: "sambanovasystems",

0 commit comments

Comments
 (0)