Skip to content

Commit cf5d962

Browse files
committed
big step
1 parent 2129a28 commit cf5d962

18 files changed

+114
-2041
lines changed

docs/inference-providers/tasks/automatic-speech-recognition.md

Lines changed: 4 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -35,208 +35,11 @@ Explore all available models and find the one that suits you best [here](https:/
3535
### Using the API
3636

3737

38-
<inferencesnippet>
38+
<InferenceSnippet
39+
pipeline=automatic-speech-recognition
3940

40-
41-
<snippet provider="fal-ai" language="python" client="huggingface_hub">
42-
43-
```python
44-
from huggingface_hub import InferenceClient
45-
46-
client = InferenceClient(
47-
provider="fal-ai",
48-
api_key="hf_***",
49-
)
50-
51-
output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3")
52-
```
53-
54-
</snippet>
55-
56-
To use the Python `InferenceClient`, see the [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.).
57-
58-
<snippet provider="fal-ai" language="python" client="requests">
59-
60-
```python
61-
import requests
62-
63-
API_URL = "https://router.huggingface.co/fal-ai/fal-ai/whisper"
64-
headers = {"Authorization": "Bearer hf_***"}
65-
66-
def query(filename):
67-
with open(filename, "rb") as f:
68-
data = f.read()
69-
response = requests.post(API_URL, headers={"Content-Type": "audio/flac", **headers}, data=data)
70-
return response.json()
71-
72-
output = query("sample1.flac")
73-
```
74-
75-
</snippet>
76-
77-
78-
<snippet provider="fal-ai" language="js" client="fetch">
79-
80-
```js
81-
async function query(data) {
82-
const response = await fetch(
83-
"https://router.huggingface.co/fal-ai/fal-ai/whisper",
84-
{
85-
headers: {
86-
Authorization: "Bearer hf_***",
87-
"Content-Type": "audio/flac"
88-
},
89-
method: "POST",
90-
body: JSON.stringify(data),
91-
}
92-
);
93-
const result = await response.json();
94-
return result;
95-
}
96-
97-
query({ inputs: "sample1.flac" }).then((response) => {
98-
console.log(JSON.stringify(response));
99-
});
100-
```
101-
102-
</snippet>
103-
104-
105-
<snippet provider="fal-ai" language="js" client="huggingface.js">
106-
107-
```js
108-
import { InferenceClient } from "@huggingface/inference";
109-
110-
const client = new InferenceClient("hf_***");
111-
112-
const data = fs.readFileSync("sample1.flac");
113-
114-
const output = await client.automaticSpeechRecognition({
115-
data,
116-
model: "openai/whisper-large-v3",
117-
provider: "fal-ai",
118-
});
119-
120-
console.log(output);
121-
```
122-
123-
</snippet>
124-
125-
To use the JavaScript `InferenceClient`, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/InferenceClient#).
126-
127-
<snippet provider="fal-ai" language="sh" client="curl">
128-
129-
```sh
130-
curl https://router.huggingface.co/fal-ai/fal-ai/whisper \
131-
-X POST \
132-
-H 'Authorization: Bearer hf_***' \
133-
-H 'Content-Type: audio/flac' \
134-
--data-binary @"sample1.flac"
135-
```
136-
137-
</snippet>
138-
139-
140-
<snippet provider="hf-inference" language="python" client="huggingface_hub">
141-
142-
```python
143-
from huggingface_hub import InferenceClient
144-
145-
client = InferenceClient(
146-
provider="hf-inference",
147-
api_key="hf_***",
148-
)
149-
150-
output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3-turbo")
151-
```
152-
153-
</snippet>
154-
155-
To use the Python `InferenceClient`, see the [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.).
156-
157-
<snippet provider="hf-inference" language="python" client="requests">
158-
159-
```python
160-
import requests
161-
162-
API_URL = "https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo"
163-
headers = {"Authorization": "Bearer hf_***"}
164-
165-
def query(filename):
166-
with open(filename, "rb") as f:
167-
data = f.read()
168-
response = requests.post(API_URL, headers={"Content-Type": "audio/flac", **headers}, data=data)
169-
return response.json()
170-
171-
output = query("sample1.flac")
172-
```
173-
174-
</snippet>
175-
176-
177-
<snippet provider="hf-inference" language="js" client="fetch">
178-
179-
```js
180-
async function query(data) {
181-
const response = await fetch(
182-
"https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo",
183-
{
184-
headers: {
185-
Authorization: "Bearer hf_***",
186-
"Content-Type": "audio/flac"
187-
},
188-
method: "POST",
189-
body: JSON.stringify(data),
190-
}
191-
);
192-
const result = await response.json();
193-
return result;
194-
}
195-
196-
query({ inputs: "sample1.flac" }).then((response) => {
197-
console.log(JSON.stringify(response));
198-
});
199-
```
200-
201-
</snippet>
202-
203-
204-
<snippet provider="hf-inference" language="js" client="huggingface.js">
205-
206-
```js
207-
import { InferenceClient } from "@huggingface/inference";
208-
209-
const client = new InferenceClient("hf_***");
210-
211-
const data = fs.readFileSync("sample1.flac");
212-
213-
const output = await client.automaticSpeechRecognition({
214-
data,
215-
model: "openai/whisper-large-v3-turbo",
216-
provider: "hf-inference",
217-
});
218-
219-
console.log(output);
220-
```
221-
222-
</snippet>
223-
224-
To use the JavaScript `InferenceClient`, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/InferenceClient#).
225-
226-
<snippet provider="hf-inference" language="sh" client="curl">
227-
228-
```sh
229-
curl https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo \
230-
-X POST \
231-
-H 'Authorization: Bearer hf_***' \
232-
-H 'Content-Type: audio/flac' \
233-
--data-binary @"sample1.flac"
234-
```
235-
236-
</snippet>
237-
238-
239-
</inferencesnippet>
41+
providersMapping={ {"fal-ai":{"modelId":"openai/whisper-large-v3","providerModelId":"fal-ai/whisper"},"hf-inference":{"modelId":"openai/whisper-large-v3-turbo","providerModelId":"openai/whisper-large-v3-turbo"}} }
42+
/>
24043

24144

24245

docs/inference-providers/tasks/feature-extraction.md

Lines changed: 4 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -35,112 +35,11 @@ Explore all available models and find the one that suits you best [here](https:/
3535
### Using the API
3636

3737

38-
<inferencesnippet>
38+
<InferenceSnippet
39+
pipeline=feature-extraction
3940

40-
41-
<snippet provider="hf-inference" language="python" client="huggingface_hub">
42-
43-
```python
44-
from huggingface_hub import InferenceClient
45-
46-
client = InferenceClient(
47-
provider="hf-inference",
48-
api_key="hf_***",
49-
)
50-
51-
result = client.feature_extraction(
52-
inputs="Today is a sunny day and I will get some ice cream.",
53-
model="intfloat/multilingual-e5-large-instruct",
54-
)
55-
```
56-
57-
</snippet>
58-
59-
To use the Python `InferenceClient`, see the [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.).
60-
61-
<snippet provider="hf-inference" language="python" client="requests">
62-
63-
```python
64-
import requests
65-
66-
API_URL = "https://router.huggingface.co/hf-inference/pipeline/feature-extraction/intfloat/multilingual-e5-large-instruct"
67-
headers = {"Authorization": "Bearer hf_***"}
68-
69-
def query(payload):
70-
response = requests.post(API_URL, headers=headers, json=payload)
71-
return response.json()
72-
73-
output = query({
74-
"inputs": "Today is a sunny day and I will get some ice cream.",
75-
})
76-
```
77-
78-
</snippet>
79-
80-
81-
<snippet provider="hf-inference" language="js" client="fetch">
82-
83-
```js
84-
async function query(data) {
85-
const response = await fetch(
86-
"https://router.huggingface.co/hf-inference/pipeline/feature-extraction/intfloat/multilingual-e5-large-instruct",
87-
{
88-
headers: {
89-
Authorization: "Bearer hf_***",
90-
"Content-Type": "application/json",
91-
},
92-
method: "POST",
93-
body: JSON.stringify(data),
94-
}
95-
);
96-
const result = await response.json();
97-
return result;
98-
}
99-
100-
query({ inputs: "Today is a sunny day and I will get some ice cream." }).then((response) => {
101-
console.log(JSON.stringify(response));
102-
});
103-
```
104-
105-
</snippet>
106-
107-
108-
<snippet provider="hf-inference" language="js" client="huggingface.js">
109-
110-
```js
111-
import { InferenceClient } from "@huggingface/inference";
112-
113-
const client = new InferenceClient("hf_***");
114-
115-
const output = await client.featureExtraction({
116-
model: "intfloat/multilingual-e5-large-instruct",
117-
inputs: "Today is a sunny day and I will get some ice cream.",
118-
provider: "hf-inference",
119-
});
120-
121-
console.log(output);
122-
```
123-
124-
</snippet>
125-
126-
To use the JavaScript `InferenceClient`, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/InferenceClient#).
127-
128-
<snippet provider="hf-inference" language="sh" client="curl">
129-
130-
```sh
131-
curl https://router.huggingface.co/hf-inference/pipeline/feature-extraction/intfloat/multilingual-e5-large-instruct \
132-
-X POST \
133-
-H 'Authorization: Bearer hf_***' \
134-
-H 'Content-Type: application/json' \
135-
-d '{
136-
"inputs": "\"Today is a sunny day and I will get some ice cream.\""
137-
}'
138-
```
139-
140-
</snippet>
141-
142-
143-
</inferencesnippet>
41+
providersMapping={ {"hf-inference":{"modelId":"mixedbread-ai/mxbai-embed-large-v1","providerModelId":"mixedbread-ai/mxbai-embed-large-v1"},"sambanova":{"modelId":"intfloat/e5-mistral-7b-instruct","providerModelId":"E5-Mistral-7B-Instruct"}} }
42+
/>
14443

14544

14645

0 commit comments

Comments
 (0)