Skip to content

Commit fb4f42e

Browse files
update new provider doc (#2870)
1 parent f629886 commit fb4f42e

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/huggingface_hub/inference/_providers/new_provider.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ You only have to add a test for overwritten methods.
7777

7878
### 5. Add VCR tests in `tests/test_inference_client.py`
7979

80-
- 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.
81-
- Add an entry in `API_KEY_ENV_VARIABLES` to define which env variable should be used
82-
- Run tests locally with `pytest tests/test_inference_client.py -k <provider>` and commit the VCR cassettes.
80+
#### a. Add test model mapping
81+
Add an entry to `_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.
82+
```python
83+
_RECOMMENDED_MODELS_FOR_VCR = {
84+
"your-provider": {
85+
"task": "model-id",
86+
...
87+
},
88+
...
89+
}
90+
```
91+
#### b. Set up authentication
92+
To record VCR cassettes, you'll need authentication:
93+
94+
- If you are a member of the provider organization (e.g., Replicate organization: https://huggingface.co/replicate), you can set the `HF_INFERENCE_TEST_TOKEN` environment variable with your HF token:
95+
```bash
96+
export HF_INFERENCE_TEST_TOKEN="your-hf-token"
97+
```
98+
99+
- If you're not a member but the provider is officially released on the Hub, you can set the `HF_INFERENCE_TEST_TOKEN` environment variable as above. If you don't have enough inference credits, we can help you record the VCR cassettes.
100+
101+
#### c. Record and commit tests
102+
103+
1. Run the tests for your provider:
104+
```bash
105+
pytest tests/test_inference_client.py -k <provider>
106+
```
107+
2. Commit the generated VCR cassettes with your PR

0 commit comments

Comments
 (0)