You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Fireworks AI provider + instructions for new provider (#2848)
* first draft of dynamic mapping
* fix imports and typing
* add back recommended models fetching for hf-inference
* fix
* avoir circular imports
* small clean up
* add default supported model list
* remove unnecessary arg
* nit
* rename function
* another nit
* fix
* fix conversational
* fix hf-inference
* add warning when status=staging
* update warning and use model_info
* update import
* fix ExpandModelProperty_T
* refacto
* fix python 3.8
* fix test
* remove newlines
* Base class for inference providers
* revert
* refacto hf-inference and fal-ai tests
* replicate tests
* samba and together tests
* reorder
* unfinished business
* some docstrings
* fix some tests
* fix HfInference does not require token
* fix inference client tests
* fix hf-inference _prepare_api_key
* fai ai get response tests
* test get_response together + replicate
* fix prepare_url
* Add Fireworks AI provider + instructions for new provider
* Update src/huggingface_hub/inference/_providers/new_provider.md
Co-authored-by: Célina <[email protected]>
* add fireworks AI to supported providers table
---------
Co-authored-by: Celina Hanouti <[email protected]>
Copy file name to clipboardExpand all lines: docs/source/en/guides/inference.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,36 +248,36 @@ You might wonder why using [`InferenceClient`] instead of OpenAI's client? There
248
248
249
249
[`InferenceClient`]'s goal is to provide the easiest interface to run inference on Hugging Face models, on any provider. It has a simple API that supports the most common tasks. Here is a table showing which providers support which tasks:
Before adding a new provider to the `huggingface_hub` library, make sure it has already been added to `huggingface.js` and is working on the Hub. Support in the Python library comes as a second step. In this guide, we are considering that the first part is complete.
4
+
5
+
### 1. Implement the provider helper
6
+
7
+
Create a new file under `src/huggingface_hub/inference/_providers/{provider_name}.py` and copy-paste the following snippet.
8
+
9
+
Implement the methods that require custom handling. Check out the base implementation to check default behavior. If you don't need to override a method, just remove it. At least one of `_prepare_payload` or `_prepare_body` must be overwritten.
10
+
11
+
If the provider supports multiple tasks that require different implementations, create dedicated subclasses for each task, following the pattern shown in `fal_ai.py`.
### 2. Register the provider helper in `__init__.py`
65
+
66
+
Go to `src/huggingface_hub/inference/_providers/__init__.py` and add your provider to `PROVIDER_T` and `PROVIDERS`.
67
+
Please try to respect alphabetical order.
68
+
69
+
### 3. Update docstring in `InferenceClient.__init__` to document your provider
70
+
71
+
### 4. Add static tests in `tests/test_inference_providers.py`
72
+
73
+
You only have to add a test for overwritten methods.
74
+
75
+
### 5. Add VCR tests in `tests/test_inference_client.py`
76
+
77
+
- Add an entry in `_RECOMMENDED_MODELS_FOR_VCR` at the top of the test module. It contains a mapping task <> test model. Model id must be the HF model id.
78
+
- Add an entry in `API_KEY_ENV_VARIABLES` to define which env variable should be used
79
+
- Run tests locally with `pytest tests/test_inference_client.py -k <provider>` and commit the VCR cassettes.
0 commit comments