Skip to content

Commit 645ff6e

Browse files
committed
Add PublicAI provider (#3367)
* Add PublicAI provider * forgot the file
1 parent ebf4311 commit 645ff6e

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

src/huggingface_hub/inference/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class InferenceClient:
133133
Note: for better compatibility with OpenAI's client, `model` has been aliased as `base_url`. Those 2
134134
arguments are mutually exclusive. If a URL is passed as `model` or `base_url` for chat completion, the `(/v1)/chat/completions` suffix path will be appended to the URL.
135135
provider (`str`, *optional*):
136-
Name of the provider to use for inference. Can be `"black-forest-labs"`, `"cerebras"`, `"cohere"`, `"fal-ai"`, `"featherless-ai"`, `"fireworks-ai"`, `"groq"`, `"hf-inference"`, `"hyperbolic"`, `"nebius"`, `"novita"`, `"nscale"`, `"openai"`, `"replicate"`, `"sambanova"`, `"scaleway"` or `"together"`.
136+
Name of the provider to use for inference. Can be `"black-forest-labs"`, `"cerebras"`, `"cohere"`, `"fal-ai"`, `"featherless-ai"`, `"fireworks-ai"`, `"groq"`, `"hf-inference"`, `"hyperbolic"`, `"nebius"`, `"novita"`, `"nscale"`, `"openai"`, `publicai`, `"replicate"`, `"sambanova"`, `"scaleway"` or `"together"`.
137137
Defaults to "auto" i.e. the first of the providers available for the model, sorted by the user's order in https://hf.co/settings/inference-providers.
138138
If model is a URL or `base_url` is passed, then `provider` is not used.
139139
token (`str`, *optional*):

src/huggingface_hub/inference/_generated/_async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class AsyncInferenceClient:
121121
Note: for better compatibility with OpenAI's client, `model` has been aliased as `base_url`. Those 2
122122
arguments are mutually exclusive. If a URL is passed as `model` or `base_url` for chat completion, the `(/v1)/chat/completions` suffix path will be appended to the URL.
123123
provider (`str`, *optional*):
124-
Name of the provider to use for inference. Can be `"black-forest-labs"`, `"cerebras"`, `"cohere"`, `"fal-ai"`, `"featherless-ai"`, `"fireworks-ai"`, `"groq"`, `"hf-inference"`, `"hyperbolic"`, `"nebius"`, `"novita"`, `"nscale"`, `"openai"`, `"replicate"`, `"sambanova"`, `"scaleway"` or `"together"`.
124+
Name of the provider to use for inference. Can be `"black-forest-labs"`, `"cerebras"`, `"cohere"`, `"fal-ai"`, `"featherless-ai"`, `"fireworks-ai"`, `"groq"`, `"hf-inference"`, `"hyperbolic"`, `"nebius"`, `"novita"`, `"nscale"`, `"openai"`, `publicai`, `"replicate"`, `"sambanova"`, `"scaleway"` or `"together"`.
125125
Defaults to "auto" i.e. the first of the providers available for the model, sorted by the user's order in https://hf.co/settings/inference-providers.
126126
If model is a URL or `base_url` is passed, then `provider` is not used.
127127
token (`str`, *optional*):

src/huggingface_hub/inference/_providers/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from .novita import NovitaConversationalTask, NovitaTextGenerationTask, NovitaTextToVideoTask
3737
from .nscale import NscaleConversationalTask, NscaleTextToImageTask
3838
from .openai import OpenAIConversationalTask
39+
from .publicai import PublicAIConversationalTask
3940
from .replicate import ReplicateImageToImageTask, ReplicateTask, ReplicateTextToImageTask, ReplicateTextToSpeechTask
4041
from .sambanova import SambanovaConversationalTask, SambanovaFeatureExtractionTask
4142
from .scaleway import ScalewayConversationalTask, ScalewayFeatureExtractionTask
@@ -59,6 +60,7 @@
5960
"novita",
6061
"nscale",
6162
"openai",
63+
"publicai",
6264
"replicate",
6365
"sambanova",
6466
"scaleway",
@@ -146,6 +148,9 @@
146148
"openai": {
147149
"conversational": OpenAIConversationalTask(),
148150
},
151+
"publicai": {
152+
"conversational": PublicAIConversationalTask(),
153+
},
149154
"replicate": {
150155
"image-to-image": ReplicateImageToImageTask(),
151156
"text-to-image": ReplicateTextToImageTask(),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ._common import BaseConversationalTask
2+
3+
4+
class PublicAIConversationalTask(BaseConversationalTask):
5+
def __init__(self):
6+
super().__init__(provider="publicai", base_url="https://api.publicai.co")

tests/test_inference_providers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from huggingface_hub.inference._providers.novita import NovitaConversationalTask, NovitaTextGenerationTask
4545
from huggingface_hub.inference._providers.nscale import NscaleConversationalTask, NscaleTextToImageTask
4646
from huggingface_hub.inference._providers.openai import OpenAIConversationalTask
47+
from huggingface_hub.inference._providers.publicai import PublicAIConversationalTask
4748
from huggingface_hub.inference._providers.replicate import (
4849
ReplicateImageToImageTask,
4950
ReplicateTask,
@@ -1122,6 +1123,15 @@ def test_prepare_payload_as_dict_feature_extraction(self):
11221123
assert payload == {"input": "Example text to embed", "model": "provider-id", "truncate": True}
11231124

11241125

1126+
class TestPublicAIProvider:
1127+
def test_prepare_url(self):
1128+
helper = PublicAIConversationalTask()
1129+
assert (
1130+
helper._prepare_url("publicai_token", "username/repo_name")
1131+
== "https://api.publicai.co/v1/chat/completions"
1132+
)
1133+
1134+
11251135
class TestNscaleProvider:
11261136
def test_prepare_route_text_to_image(self):
11271137
helper = NscaleTextToImageTask()

0 commit comments

Comments
 (0)