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
* A chat completions model deployment. If you don't have one read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
29
+
* A chat completions model deployment. If you don't have one, read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
30
30
31
31
* This example uses `mistral-large-2407`.
32
32
@@ -42,7 +42,7 @@ ChatCompletionsClient client = new ChatCompletionsClient(
42
42
);
43
43
```
44
44
45
-
If you have configured the resource to with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
45
+
If you've configured the resource with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs are not guaranteed to be valid JSON.
184
+
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs aren't guaranteed to be valid JSON.
185
185
186
186
If you want to pass a parameter that isn't in the list of supported parameters, you can pass it to the underlying model using *extra parameters*. See [Pass extra parameters to the model](#pass-extra-parameters-to-the-model).
> 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).
403
-
404
-
## Use chat completions with images
405
-
406
-
Some models can reason across text and images and generate text completions based on both kinds of input. In this section, you explore the capabilities of Some models for vision in a chat fashion:
407
-
408
-
> [!IMPORTANT]
409
-
> Some models support only one image for each turn in the chat conversation and only the last image is retained in context. If you add multiple images, it results in an error.
410
-
411
-
To see this capability, download an image and encode the information as `base64` string. The resulting data should be inside of a [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs):
:::image type="content" source="../../../../ai-foundry/media/how-to/sdks/small-language-models-chart-example.jpg" alt-text="A chart displaying the relative capabilities between large language models and small language models." lightbox="../../../../ai-foundry/media/how-to/sdks/small-language-models-chart-example.jpg":::
427
-
428
-
Now, create a chat completion request with the image:
ASSISTANT: The chart illustrates that larger models tend to perform better in quality, as indicated by their size in billions of parameters. However, there are exceptions to this trend, such as Phi-3-medium and Phi-3-small, which outperform smaller models in quality. This suggests that while larger models generally have an advantage, there might be other factors at play that influence a model's performance.
* A chat completions model deployment. If you don't have one read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
29
+
* A chat completions model deployment. If you don't have one, read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
30
30
31
31
* This example uses `mistral-large-2407`.
32
32
@@ -41,7 +41,7 @@ ChatCompletionsClient client = new ChatCompletionsClientBuilder()
41
41
.buildClient();
42
42
```
43
43
44
-
If you have configured the resource to with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
44
+
If you've configured the resource with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
#### Explore more parameters supported by the inference client
121
121
122
122
Explore other parameters that you can specify in the inference client. For a full list of all the supported parameters and their corresponding documentation, see [Azure AI Model Inference API reference](https://aka.ms/azureai/modelinference).
123
-
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs are not guaranteed to be valid JSON.
123
+
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs aren't guaranteed to be valid JSON.
124
124
125
125
If you want to pass a parameter that isn't in the list of supported parameters, you can pass it to the underlying model using *extra parameters*. See [Pass extra parameters to the model](#pass-extra-parameters-to-the-model).
* A chat completions model deployment. If you don't have one read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
29
+
* A chat completions model deployment. If you don't have one, read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
30
30
31
31
## Use chat completions
32
32
@@ -44,7 +44,7 @@ const client = new ModelClient(
44
44
);
45
45
```
46
46
47
-
If you have configured the resource to with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
47
+
If you've configured the resource with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
48
48
49
49
50
50
```javascript
@@ -177,7 +177,7 @@ var response = await client.path("/chat/completions").post({
177
177
});
178
178
```
179
179
180
-
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs are not guaranteed to be valid JSON.
180
+
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs aren't guaranteed to be valid JSON.
181
181
182
182
If you want to pass a parameter that isn't in the list of supported parameters, you can pass it to the underlying model using *extra parameters*. See [Pass extra parameters to the model](#pass-extra-parameters-to-the-model).
183
183
@@ -388,82 +388,3 @@ catch (error) {
388
388
> [!TIP]
389
389
> 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).
390
390
391
-
## Use chat completions with images
392
-
393
-
Some models can reason across text and images and generate text completions based on both kinds of input. In this section, you explore the capabilities of Some models for vision in a chat fashion:
394
-
395
-
> [!IMPORTANT]
396
-
> Some models support only one image for each turn in the chat conversation and only the last image is retained in context. If you add multiple images, it results in an error.
397
-
398
-
To see this capability, download an image and encode the information as `base64` string. The resulting data should be inside of a [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs):
:::image type="content" source="../../../../ai-foundry/media/how-to/sdks/small-language-models-chart-example.jpg" alt-text="A chart displaying the relative capabilities between large language models and small language models." lightbox="../../../../ai-foundry/media/how-to/sdks/small-language-models-chart-example.jpg":::
421
-
422
-
Now, create a chat completion request with the image:
423
-
424
-
425
-
```javascript
426
-
var messages = [
427
-
{ role:"system", content:"You are a helpful assistant that can generate responses based on images." },
428
-
{ role:"user", content:
429
-
[
430
-
{ type:"text", text:"Which conclusion can be extracted from the following chart?" },
431
-
{ type:"image_url", image:
432
-
{
433
-
url: data_url
434
-
}
435
-
}
436
-
]
437
-
}
438
-
];
439
-
440
-
var response =awaitclient.path("/chat/completions").post({
441
-
body: {
442
-
messages: messages,
443
-
temperature:0,
444
-
top_p:1,
445
-
max_tokens:2048,
446
-
}
447
-
});
448
-
```
449
-
450
-
The response is as follows, where you can see the model's usage statistics:
ASSISTANT: The chart illustrates that larger models tend to perform better in quality, as indicated by their size in billions ofparameters. However, there are exceptions to this trend, such as Phi-3-medium and Phi-3-small, which outperform smaller models inquality. This suggests that while larger models generally have an advantage, there might be other factors at play that influence a model's performance.
* A chat completions model deployment. If you don't have one read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
29
+
* A chat completions model deployment. If you don't have one, read [Add and configure models to Azure AI services](../../how-to/create-model-deployments.md) to add a chat completions model to your resource.
30
30
31
31
* This example uses `mistral-large-2407`.
32
32
@@ -46,7 +46,7 @@ client = ChatCompletionsClient(
46
46
)
47
47
```
48
48
49
-
If you have configured the resource to with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
49
+
If you've configured the resource with **Microsoft Entra ID** support, you can use the following code snippet to create a client.
50
50
51
51
52
52
```python
@@ -166,7 +166,7 @@ response = client.complete(
166
166
)
167
167
```
168
168
169
-
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs are not guaranteed to be valid JSON.
169
+
Some models don't support JSON output formatting. You can always prompt the model to generate JSON outputs. However, such outputs aren't guaranteed to be valid JSON.
170
170
171
171
If you want to pass a parameter that isn't in the list of supported parameters, you can pass it to the underlying model using *extra parameters*. See [Pass extra parameters to the model](#pass-extra-parameters-to-the-model).
172
172
@@ -373,76 +373,3 @@ except HttpResponseError as ex:
373
373
> [!TIP]
374
374
> 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).
375
375
376
-
## Use chat completions with images
377
-
378
-
Some models can reason across text and images and generate text completions based on both kinds of input. In this section, you explore the capabilities of Some models for vision in a chat fashion:
379
-
380
-
> [!IMPORTANT]
381
-
> Some models support only one image for each turn in the chat conversation and only the last image is retained in context. If you add multiple images, it results in an error.
382
-
383
-
To see this capability, download an image and encode the information as `base64` string. The resulting data should be inside of a [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs):
:::image type="content" source="../../../../ai-foundry/media/how-to/sdks/small-language-models-chart-example.jpg" alt-text="A chart displaying the relative capabilities between large language models and small language models." lightbox="../../../../ai-foundry/media/how-to/sdks/small-language-models-chart-example.jpg":::
409
-
410
-
Now, create a chat completion request with the image:
411
-
412
-
413
-
```python
414
-
from azure.ai.inference.models import TextContentItem, ImageContentItem, ImageUrl
415
-
response = client.complete(
416
-
messages=[
417
-
SystemMessage("You are a helpful assistant that can generate responses based on images."),
418
-
UserMessage(content=[
419
-
TextContentItem(text="Which conclusion can be extracted from the following chart?"),
420
-
ImageContentItem(image=ImageUrl(url=data_url))
421
-
]),
422
-
],
423
-
temperature=0,
424
-
top_p=1,
425
-
max_tokens=2048,
426
-
)
427
-
```
428
-
429
-
The response is as follows, where you can see the model's usage statistics:
ASSISTANT: The chart illustrates that larger models tend to perform better in quality, as indicated by their size in billions of parameters. However, there are exceptions to this trend, such as Phi-3-medium and Phi-3-small, which outperform smaller models in quality. This suggests that while larger models generally have an advantage, there might be other factors at play that influence a model's performance.
0 commit comments