Skip to content

Commit cf0ac82

Browse files
committed
fix again
1 parent 7f9643c commit cf0ac82

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

docs/api-inference/tasks/chat-completion.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ curl 'https://api-inference.huggingface.co/models/google/gemma-2-2b-it/v1/chat/c
8080

8181
<python>
8282
```py
83-
<huggingface_hub>
83+
# With huggingface_hub client
84+
8485
from huggingface_hub import InferenceClient
8586

8687
client = InferenceClient(api_key="hf_***")
@@ -101,9 +102,9 @@ stream = client.chat.completions.create(
101102

102103
for chunk in stream:
103104
print(chunk.choices[0].delta.content, end="")
104-
</huggingface_hub>
105105

106-
<openai>
106+
# With openai client
107+
107108
from openai import OpenAI
108109

109110
client = OpenAI(
@@ -127,15 +128,15 @@ stream = client.chat.completions.create(
127128

128129
for chunk in stream:
129130
print(chunk.choices[0].delta.content, end="")
130-
</openai>
131131
```
132132

133133
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.chat_completion).
134134
</python>
135135

136136
<js>
137137
```js
138-
<huggingface_hub>
138+
# With huggingface_hub client
139+
139140
import { HfInference } from "@huggingface/inference"
140141

141142
const client = new HfInference("hf_***")
@@ -160,9 +161,9 @@ for await (const chunk of stream) {
160161
console.log(newContent);
161162
}
162163
}
163-
</huggingface_hub>
164164

165-
<openai>
165+
# With openai client
166+
166167
import { OpenAI } from "openai"
167168

168169
const client = new OpenAI({
@@ -191,7 +192,6 @@ for await (const chunk of stream) {
191192
console.log(newContent);
192193
}
193194
}
194-
</openai>
195195
```
196196

197197
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#chatcompletion).
@@ -238,7 +238,8 @@ curl 'https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Visio
238238

239239
<python>
240240
```py
241-
<huggingface_hub>
241+
# With huggingface_hub client
242+
242243
from huggingface_hub import InferenceClient
243244

244245
client = InferenceClient(api_key="hf_***")
@@ -270,9 +271,9 @@ stream = client.chat.completions.create(
270271

271272
for chunk in stream:
272273
print(chunk.choices[0].delta.content, end="")
273-
</huggingface_hub>
274274

275-
<openai>
275+
# With openai client
276+
276277
from openai import OpenAI
277278

278279
client = OpenAI(
@@ -307,15 +308,15 @@ stream = client.chat.completions.create(
307308

308309
for chunk in stream:
309310
print(chunk.choices[0].delta.content, end="")
310-
</openai>
311311
```
312312

313313
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.chat_completion).
314314
</python>
315315

316316
<js>
317317
```js
318-
<huggingface_hub>
318+
# With huggingface_hub client
319+
319320
import { HfInference } from "@huggingface/inference"
320321

321322
const client = new HfInference("hf_***")
@@ -351,9 +352,9 @@ for await (const chunk of stream) {
351352
console.log(newContent);
352353
}
353354
}
354-
</huggingface_hub>
355355

356-
<openai>
356+
# With openai client
357+
357358
import { OpenAI } from "openai"
358359

359360
const client = new OpenAI({
@@ -393,7 +394,6 @@ for await (const chunk of stream) {
393394
console.log(newContent);
394395
}
395396
}
396-
</openai>
397397
```
398398

399399
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#chatcompletion).

docs/api-inference/tasks/image-text-to-text.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ curl https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Vision
4646

4747
<python>
4848
```py
49-
<huggingface_hub>
49+
# With huggingface_hub client
50+
5051
import requests
5152

5253
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Vision-Instruct"
@@ -67,9 +68,9 @@ stream = client.chat.completions.create(
6768

6869
for chunk in stream:
6970
print(chunk.choices[0].delta.content, end="")
70-
</huggingface_hub>
7171

72-
<openai>
72+
# With openai client
73+
7374
import requests
7475

7576
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-11B-Vision-Instruct"
@@ -93,7 +94,6 @@ stream = client.chat.completions.create(
9394

9495
for chunk in stream:
9596
print(chunk.choices[0].delta.content, end="")
96-
</openai>
9797
```
9898

9999
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.image_text-to-text).

scripts/api-inference/scripts/generate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ const formatSnippets = (result: snippets.types.InferenceSnippet | snippets.types
106106
return snippet.content;
107107
}
108108

109-
// For multiple snippets, return just the content with client info
109+
// For multiple snippets, add comments between them
110110
return result
111111
.map(snippet =>
112-
`<${snippet.client || defaultClient}>\n${snippet.content}\n</${snippet.client || defaultClient}>`
112+
`# With ${snippet.client || defaultClient} client\n\n${snippet.content}`
113113
)
114114
.join('\n\n');
115115
};
116116

117+
118+
117119
const GET_SNIPPET_FN = {
118120
curl: (modelData: any, token: string) => {
119121
const result = snippets.curl.getCurlInferenceSnippet(modelData, token);

0 commit comments

Comments
 (0)