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
Copy file name to clipboardExpand all lines: docs/api-inference/tasks/chat-completion.md
+96-7Lines changed: 96 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,20 +14,20 @@ For more details, check out:
14
14
15
15
## Chat Completion
16
16
17
-
Generate a response given a list of messages.
18
-
This is a subtask of [`text-generation`](./text_generation) designed to generate responses in a conversational context.
19
-
20
-
17
+
Generate a response given a list of messages in a conversational context, supporting both conversational Language Models (LLMs) and conversational Vision-Language Models (VLMs).
18
+
This is a subtask of [`text-generation`](./text_generation) and [`image-text-to-text`](./image_text_to_text).
21
19
22
20
### Recommended models
23
21
22
+
#### Conversational Large Language Models (LLMs)
24
23
-[google/gemma-2-2b-it](https://huggingface.co/google/gemma-2-2b-it): A text-generation model trained to follow instructions.
25
24
-[meta-llama/Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct): Very powerful text generation model trained to follow instructions.
26
25
-[microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct): Small yet powerful text generation model.
@@ -70,7 +72,7 @@ for message in client.chat_completion(
70
72
print(message.choices[0].delta.content, end="")
71
73
```
72
74
73
-
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).
75
+
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.conversational_text-generation).
74
76
</python>
75
77
76
78
<js>
@@ -88,7 +90,94 @@ for await (const chunk of inference.chatCompletionStream({
88
90
}
89
91
```
90
92
91
-
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#chatcompletion).
93
+
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#conversationaltext-generation).
{"type":"text", "text":"Describe this image in one sentence."},
144
+
],
145
+
}
146
+
],
147
+
max_tokens=500,
148
+
stream=True,
149
+
):
150
+
print(message.choices[0].delta.content, end="")
151
+
```
152
+
153
+
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.conversational_image-text-to-text).
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#conversationalimage-text-to-text).
Copy file name to clipboardExpand all lines: docs/api-inference/tasks/image-text-to-text.md
+1-16Lines changed: 1 addition & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,21 +109,6 @@ To use the JavaScript client, see `huggingface.js`'s [package reference](https:/
109
109
110
110
### API specification
111
111
112
-
#### Request
113
-
114
-
115
-
116
-
Some options can be configured by passing headers to the Inference API. Here are the available headers:
117
-
118
-
| Headers |||
119
-
| :--- | :--- | :--- |
120
-
|**authorization**|_string_| Authentication header in the form `'Bearer: hf_****'` when `hf_****` is a personal user access token with Inference API permission. You can generate one from [your settings page](https://huggingface.co/settings/tokens). |
121
-
|**x-use-cache**|_boolean, default to `true`_| There is a cache layer on the inference API to speed up requests we have already seen. Most models can use those results as they are deterministic (meaning the outputs will be the same anyway). However, if you use a nondeterministic model, you can set this parameter to prevent the caching mechanism from being used, resulting in a real new query. Read more about caching [here](../parameters#caching]). |
122
-
|**x-wait-for-model**|_boolean, default to `false`_| If the model is not ready, wait for it instead of receiving 503. It limits the number of requests required to get your inference done. It is advised to only set this flag to true after receiving a 503 error, as it will limit hanging in your application to known places. Read more about model availability [here](../overview#eligibility]). |
123
-
124
-
For more information about Inference API headers, check out the parameters [guide](../parameters).
125
-
126
-
#### Response
127
-
112
+
For the API specification of conversational image-text-to-text models, please refer to the [Chat Completion API documentation](https://huggingface.co/docs/api-inference/tasks/chat-completion#api-specification).
"inputs": "Can you please let us know more details about your ",
66
+
})
71
67
```
72
68
73
69
To use the Python client, see `huggingface_hub`'s [package reference](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.text_generation).
query({"inputs":"Can you please let us know more details about your "}).then((response) => {
91
+
console.log(JSON.stringify(response));
92
+
});
89
93
```
90
94
91
95
To use the JavaScript client, see `huggingface.js`'s [package reference](https://huggingface.co/docs/huggingface.js/inference/classes/HfInference#textgeneration).
0 commit comments