Skip to content

Commit 69874ae

Browse files
authored
Add PublicAI provider (#3367)
* Add PublicAI provider * forgot the file
1 parent 6faf2d7 commit 69874ae

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
@@ -130,7 +130,7 @@ class InferenceClient:
130130
Note: for better compatibility with OpenAI's client, `model` has been aliased as `base_url`. Those 2
131131
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.
132132
provider (`str`, *optional*):
133-
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"`.
133+
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"`.
134134
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.
135135
If model is a URL or `base_url` is passed, then `provider` is not used.
136136
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
@@ -118,7 +118,7 @@ class AsyncInferenceClient:
118118
Note: for better compatibility with OpenAI's client, `model` has been aliased as `base_url`. Those 2
119119
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.
120120
provider (`str`, *optional*):
121-
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"`.
121+
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"`.
122122
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.
123123
If model is a URL or `base_url` is passed, then `provider` is not used.
124124
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,
@@ -1147,6 +1148,15 @@ def test_prepare_payload_as_dict_feature_extraction(self):
11471148
assert payload == {"input": "Example text to embed", "model": "provider-id", "truncate": True}
11481149

11491150

1151+
class TestPublicAIProvider:
1152+
def test_prepare_url(self):
1153+
helper = PublicAIConversationalTask()
1154+
assert (
1155+
helper._prepare_url("publicai_token", "username/repo_name")
1156+
== "https://api.publicai.co/v1/chat/completions"
1157+
)
1158+
1159+
11501160
class TestNscaleProvider:
11511161
def test_prepare_route_text_to_image(self):
11521162
helper = NscaleTextToImageTask()

0 commit comments

Comments
 (0)