-
Notifications
You must be signed in to change notification settings - Fork 844
✨ Support for Featherless.ai as inference provider #3081
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4e32c5f
add featherless-ai provider
pohnean 3595473
add featherless to the table
hanouticelina 192b722
Apply style fixes
github-actions[bot] f324e53
Update src/huggingface_hub/inference/_providers/featherless_ai.py
pohnean b479672
update featherless api provider + pass api_key to prepare_mapping_inf…
pohnean 737f5c5
Revert "Auxiliary commit to revert individual files from b479672fa2d4…
pohnean e312d1d
Merge branch 'main' into featherless-ai
pohnean a382134
Merge branch 'main' into featherless-ai
hanouticelina 25ffbea
Update src/huggingface_hub/inference/_providers/featherless_ai.py
hanouticelina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/huggingface_hub/inference/_providers/featherless_ai.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| from typing import Any, Dict, Optional, Union | ||
|
|
||
| from huggingface_hub.hf_api import InferenceProviderMapping | ||
| from huggingface_hub.inference._common import RequestParameters, _as_dict | ||
|
|
||
| from ._common import BaseConversationalTask, BaseTextGenerationTask, filter_none | ||
|
|
||
|
|
||
| _PROVIDER = "featherless-ai" | ||
| _BASE_URL = "https://api.featherless.ai" | ||
|
|
||
|
|
||
| class FeatherlessTextGenerationTask(BaseTextGenerationTask): | ||
| def __init__(self): | ||
| super().__init__(provider=_PROVIDER, base_url=_BASE_URL) | ||
|
|
||
| def _prepare_payload_as_dict( | ||
| self, inputs: Any, parameters: Dict, provider_mapping_info: InferenceProviderMapping | ||
| ) -> Optional[Dict]: | ||
| params = filter_none(parameters.copy()) | ||
| params["max_tokens"] = params.pop("max_new_tokens", None) | ||
|
|
||
| return {"prompt": inputs, **params, "model": provider_mapping_info.provider_id} | ||
|
|
||
| def get_response(self, response: Union[bytes, Dict], request_params: Optional[RequestParameters] = None) -> Any: | ||
| output = _as_dict(response)["choices"][0] | ||
| return { | ||
| "generated_text": output["text"], | ||
| "details": { | ||
| "finish_reason": output.get("finish_reason"), | ||
| "seed": output.get("seed"), | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| class FeatherlessConversationalTask(BaseConversationalTask): | ||
| def __init__(self): | ||
| super().__init__(provider=_PROVIDER, base_url=_BASE_URL) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.