Skip to content

Commit 51bd8dc

Browse files
Merge pull request #1227 from santiagxf/santiagxf-patch-2
Update llama-index.md
2 parents 372f067 + 73e1d57 commit 51bd8dc

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

articles/ai-studio/how-to/develop/llama-index.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ To run this tutorial, you need:
4545
```bash
4646
pip install -U llama-index-llms-azure-inference
4747
pip install -U llama-index-embeddings-azure-inference
48-
```
48+
```
49+
50+
> [!IMPORTANT]
51+
> Using the [Azure AI model inference service](https://aka.ms/aiservices/inference) requires version `0.2.4` for `llama-index-llms-azure-inference` or `llama-index-embeddings-azure-inference`.
4952

5053
## Configure the environment
5154

@@ -67,7 +70,7 @@ export AZURE_INFERENCE_ENDPOINT="<your-model-endpoint-goes-here>"
6770
export AZURE_INFERENCE_CREDENTIAL="<your-key-goes-here>"
6871
```
6972
70-
Once configured, create a client to connect to the endpoint. The parameter `model_name` in the constructor is not required for endpoints serving a single model, like serverless endpoints.
73+
Once configured, create a client to connect to the endpoint.
7174
7275
```python
7376
import os
@@ -80,7 +83,20 @@ llm = AzureAICompletionsModel(
8083
```
8184
8285
> [!TIP]
83-
> If your model is an OpenAI model deployed to Azure OpenAI service or AI services resource, configure the client as indicated at [Azure OpenAI models](#azure-openai-models).
86+
> If your model is an OpenAI model deployed to Azure OpenAI service or AI services resource, configure the client as indicated at [Azure OpenAI models and Azure AI model inference service](#azure-openai-models-and-azure-ai-model-infernece-service).
87+
88+
If your endpoint is serving more than one model, like with the [Azure AI model inference service](../../ai-services/model-inference.md) or [GitHub Models](https://github.com/marketplace/models), you have to indicate `model_name` parameter:
89+
90+
```python
91+
import os
92+
from llama_index.llms.azure_inference import AzureAICompletionsModel
93+
94+
llm = AzureAICompletionsModel(
95+
endpoint=os.environ["AZURE_INFERENCE_ENDPOINT"],
96+
credential=os.environ["AZURE_INFERENCE_CREDENTIAL"],
97+
model_name="mistral-large-2407",
98+
)
99+
```
84100
85101
Alternatively, if your endpoint support Microsoft Entra ID, you can use the following code to create the client:
86102
@@ -112,22 +128,23 @@ llm = AzureAICompletionsModel(
112128
)
113129
```
114130

115-
### Azure OpenAI models
131+
### Azure OpenAI models and Azure AI model infernece service
116132

117-
If you are using Azure OpenAI models with key-based authentication, you need to pass the authentication key in the header `api-key`, which is the one expected in the Azure OpenAI service and in Azure AI Services. This configuration is not required if you are using Microsoft Entra ID (formerly known as Azure AD). The following example shows how to configure the client:
133+
If you are using Azure OpenAI models or [Azure AI model inference service](../../ai-services/model-inference.md), ensure you have at least version `0.2.4` of the LlamaIndex integration. Use `api_version` parameter in case you need to select a specific `api_version`. For the [Azure AI model inference service](../../ai-services/model-inference.md), you need to pass `model_name` parameter:
118134

119135
```python
120-
import os
121136
from llama_index.llms.azure_inference import AzureAICompletionsModel
122137
123138
llm = AzureAICompletionsModel(
124139
endpoint=os.environ["AZURE_INFERENCE_ENDPOINT"],
125-
credential="",
126-
client_kwargs={"headers" : { "api-key": os.environ["AZURE_INFERENCE_CREDENTIAL"] } }
140+
credential=os.environ["AZURE_INFERENCE_CREDENTIAL"],
141+
model_name="gpt-4o",
142+
api_version="2024-05-01-preview",
127143
)
128144
```
129145

130-
Notice that `credentials` is still being passed with an empty value since it's a required parameter.
146+
> [!TIP]
147+
> Using a wrong `api_version` or one not supported by the model results in a `ResourceNotFound` exception.
131148

132149
### Inference parameters
133150

0 commit comments

Comments
 (0)