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
> Verify that you have deployed the model to Azure AI Services resource with The Azure AI Model Inference API. `Deepseek-R1` is also available as standard deployments. However, those endpoints don't take the parameter `model` as explained in this tutorial. You can verify that by going to [Azure AI Foundry portal]() > Models + endpoints, and verify that the model is listed under the section **Azure AI Services**.
58
+
---
46
59
47
60
If you have configured the resource to with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
48
61
62
+
# [OpenAI](#tab/openai)
63
+
64
+
```python
65
+
import os
66
+
from openai import AzureOpenAI
67
+
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
Response: <think>Okay, the user is asking how many languages exist in the world. I need to provide a clear and accurate answer...</think>As of now, it's estimated that there are about 7,000 languages spoken around the world. However, this number can vary as some languages become extinct and new ones develop. It's also important to note that the number of speakers can greatly vary between languages, with some having millions of speakers and others only a few hundred.
144
+
Response: As of now, it's estimated that there are about 7,000 languages spoken around the world. However, this number can vary as some languages become extinct and new ones develop. It's also important to note that the number of speakers can greatly vary between languages, with some having millions of speakers and others only a few hundred.
Response: <think>Okay, the user is asking how many languages exist in the world. I need to provide a clear and accurate answer...</think>As of now, it's estimated that there are about 7,000 languages spoken around the world. However, this number can vary as some languages become extinct and new ones develop. It's also important to note that the number of speakers can greatly vary between languages, with some having millions of speakers and others only a few hundred.
165
+
Model: deepseek-r1
166
+
Usage:
167
+
Prompt tokens: 11
168
+
Total tokens: 897
169
+
Completion tokens: 886
170
+
```
171
+
---
100
172
101
173
### Reasoning content
102
174
103
-
Some reasoning models, like DeepSeek-R1, generate completions and include the reasoning behind it. The reasoning associated with the completion is included in the response's content within the tags `<think>` and `</think>`. The model may select on which scenarios to generate reasoning content. You can extract the reasoning content from the response to understand the model's thought process as follows:
175
+
Some reasoning models, like DeepSeek-R1, generate completions and include the reasoning behind it.
176
+
177
+
# [OpenAI](#tab/openai)
178
+
179
+
The reasoning associated with the completion is included in the field `reasoning_content`. The model may select on which scenearios to generate reasoning content.
Thinking: Okay, the user is asking how many languages exist in the world. I need to provide a clear and accurate answer...
188
+
```
189
+
190
+
# [Model Inference (preview)](#tab/inference)
191
+
192
+
The reasoning associated with the completion is included in the response's content within the tags `<think>` and `</think>`. The model may select on which scenarios to generate reasoning content. You can extract the reasoning content from the response to understand the model's thought process as follows:
Thinking: Okay, the user is asking how many languages exist in the world. I need to provide a clear and accurate answer. Let's start by recalling the general consensus from linguistic sources. I remember that the number often cited is around 7,000, but maybe I should check some reputable organizations.\n\nEthnologue is a well-known resource for language data, and I think they list about 7,000 languages. But wait, do they update their numbers? It might be around 7,100 or so. Also, the exact count can vary because some sources might categorize dialects differently or have more recent data. \n\nAnother thing to consider is language endangerment. Many languages are endangered, with some having only a few speakers left. Organizations like UNESCO track endangered languages, so mentioning that adds context. Also, the distribution isn't even. Some countries have hundreds of languages, like Papua New Guinea with over 800, while others have just a few. \n\nA user might also wonder why the exact number is hard to pin down. It's because the distinction between a language and a dialect can be political or cultural. For example, Mandarin and Cantonese are considered dialects of Chinese by some, but they're mutually unintelligible, so others classify them as separate languages. Also, some regions are under-researched, making it hard to document all languages. \n\nI should also touch on language families. The 7,000 languages are grouped into families like Indo-European, Sino-Tibetan, Niger-Congo, etc. Maybe mention a few of the largest families. But wait, the question is just about the count, not the families. Still, it's good to provide a bit more context. \n\nI need to make sure the information is up-to-date. Let me think – recent estimates still hover around 7,000. However, languages are dying out rapidly, so the number decreases over time. Including that note about endangerment and language extinction rates could be helpful. For instance, it's often stated that a language dies every few weeks. \n\nAnother point is sign languages. Does the count include them? Ethnologue includes some, but not all sources might. If the user is including sign languages, that adds more to the count, but I think the 7,000 figure typically refers to spoken languages. For thoroughness, maybe mention that there are also over 300 sign languages. \n\nSummarizing, the answer should state around 7,000, mention Ethnologue's figure, explain why the exact number varies, touch on endangerment, and possibly note sign languages as a separate category. Also, a brief mention of Papua New Guinea as the most linguistically diverse country. \n\nWait, let me verify Ethnologue's current number. As of their latest edition (25th, 2022), they list 7,168 living languages. But I should check if that's the case. Some sources might round to 7,000. Also, SIL International publishes Ethnologue, so citing them as reference makes sense. \n\nOther sources, like Glottolog, might have a different count because they use different criteria. Glottolog might list around 7,000 as well, but exact numbers vary. It's important to highlight that the count isn't exact because of differing definitions and ongoing research. \n\nIn conclusion, the approximate number is 7,000, with Ethnologue being a key source, considerations of endangerment, and the challenges in counting due to dialect vs. language distinctions. I should make sure the answer is clear, acknowledges the variability, and provides key points succinctly.
125
-
126
-
Answer: The exact number of languages in the world is challenging to determine due to differences in definitions (e.g., distinguishing languages from dialects) and ongoing documentation efforts. However, widely cited estimates suggest there are approximately **7,000 languages** globally.
127
-
Model: DeepSeek-R1
128
-
Usage:
129
-
Prompt tokens: 11
130
-
Total tokens: 897
131
-
Completion tokens: 886
206
+
Thinking: Okay, the user is asking how many languages exist in the world. I need to provide a clear and accurate answer. Let's start...
132
207
```
208
+
---
133
209
134
210
When making multi-turn conversations, it's useful to avoid sending the reasoning content in the chat history as reasoning tends to generate long explanations.
135
211
@@ -141,6 +217,19 @@ You can _stream_ the content to get it as it's being generated. Streaming conten
141
217
142
218
To stream completions, set`stream=True` when you call the model.
143
219
220
+
# [OpenAI](#tab/openai)
221
+
222
+
```python
223
+
response= client.chat.completions.create(
224
+
model="deepseek-r1",
225
+
messages=[
226
+
{"role": "user", "content": "How many languages are in the world?"}
227
+
],
228
+
stream=True
229
+
)
230
+
```
231
+
232
+
# [Model Inference (preview)](#tab/inference)
144
233
145
234
```python
146
235
response= client.complete(
@@ -152,9 +241,34 @@ response = client.complete(
152
241
stream=True,
153
242
)
154
243
```
244
+
---
155
245
156
246
To visualize the output, define a helper function to print the stream. The following example implements a routing that stream only the answer without the reasoning content:
You can visualize how streaming generates content:
178
293
@@ -198,6 +313,10 @@ The Azure AI Model Inference API supports [Azure AI Content Safety](https://aka.
198
313
199
314
The following example shows how to handle events when the model detects harmful content in the input prompt.
200
315
316
+
# [OpenAI](#tab/openai)
317
+
318
+
# [Model Inference (preview)](#tab/inference)
319
+
201
320
```python
202
321
from azure.ai.inference.models import AssistantMessage, UserMessage
203
322
@@ -220,6 +339,7 @@ except HttpResponseError as ex:
220
339
raise
221
340
raise
222
341
```
342
+
---
223
343
224
344
> [!TIP]
225
345
> To learn more about how you can configure and control Azure AI Content Safety settings, check the [Azure AI Content Safety documentation](https://aka.ms/azureaicontentsafety).
0 commit comments