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: articles/ai-studio/how-to/develop/llama-index.md
+30-5Lines changed: 30 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ author: eric-urban
13
13
14
14
# Develop applications with LlamaIndex and Azure AI studio
15
15
16
-
In this article, you learn how to use [LlamaIndex](https://github.com/run-llama/llama_index) with models deployed from the Azure AI model catalog deployed to Azure AI studio.
16
+
In this article, you learn how to use [LlamaIndex](https://github.com/run-llama/llama_index) with models deployed from the Azure AI model catalog in Azure AI studio.
17
17
18
18
Models deployed to Azure AI studio can be used with LlamaIndex in two ways:
19
19
@@ -49,7 +49,7 @@ To run this tutorial, you need:
49
49
50
50
## Configure the environment
51
51
52
-
To use LLMs deployed in Azure AI studio, you need the endpoint and credentials to connect to it. The parameter `model_name` is not required for endpoints serving a single model, like Managed Online Endpoints. Follow these steps to get the information you need from the model you want to use:
52
+
To use LLMs deployed in Azure AI studio, you need the endpoint and credentials to connect to it. Follow these steps to get the information you need from the model you want to use:
53
53
54
54
1. Go to the [Azure AI studio](https://ai.azure.com/).
55
55
2. Go to deployments and selectthe model you deployed as indicated in the prerequisites.
> > Note: When using Microsoft Entra ID, make sure that the endpoint was deployed with that authentication method and that you have the required permissions to invoke it.
99
+
> When using Microsoft Entra ID, make sure that the endpoint was deployed with that authentication method and that you have the required permissions to invoke it.
95
100
96
101
If you are planning to use asynchronous calling, it's a best practice to use the asynchronous version for the credentials:
97
102
98
103
```python
99
104
from azure.identity.aio import (
100
105
DefaultAzureCredential as DefaultAzureCredentialAsync,
101
106
)
107
+
from llama_index.llms.azure_inference import AzureAICompletionsModel
Use the `chat` endpoint for chat instruction models. The `complete` method is still available for model of type`chat-completions`. On those cases, your input text is converted to a message with `role="user"`.
141
+
You can use the client directly or [#configure-the-models-used-by-your-code](Configure the models used by your code) in LlamaIndex. To use the model directly, use the `chat` method for chat instruction models:
136
142
137
143
```python
138
144
from llama_index.core.llms import ChatMessage
@@ -156,9 +162,11 @@ for r in response:
156
162
print(r.delta, end="")
157
163
```
158
164
165
+
The `complete` method is still available for model of type`chat-completions`. On those cases, your input text is converted to a message with `role="user"`.
166
+
159
167
## Use embeddings models
160
168
161
-
In the same way you create an LLM client, you can connect to an embedding model. In the following example, we are setting again the environment variable to now point to an embeddings model:
169
+
In the same way you create an LLM client, you can connect to an embeddings model. In the following example, we are setting the environment variable to now point to an embeddings model:
The following example shows a simple test to verify it works:
188
+
189
+
```python
190
+
from llama_index.core.schema import TextNode
191
+
192
+
nodes = [
193
+
TextNode(
194
+
text="Before college the two main things I worked on, "
195
+
"outside of school, were writing and programming."
196
+
)
197
+
]
198
+
response = embed_model(nodes=nodes)
199
+
print(response[0].embedding)
200
+
```
201
+
179
202
## Configure the models used by your code
180
203
181
204
You can use the LLM or embeddings model client individually in the code you develop with LlamaIndex or you can configure the entire session using the `Settings` options. Configuring the session has the advantage of all your code using the same models for all the operations.
@@ -200,3 +223,5 @@ In general, you use a combination of both strategies.
200
223
## Related content
201
224
202
225
* [How to get started with Azure AI SDKs](sdk-overview.md)
226
+
* [Reference for LlamaIndex Embeddings Integration](https://llamahub.ai/l/embeddings/llama-index-embeddings-azure-inference)
227
+
* [Reference for LlamaIndex LLMs Integration](https://llamahub.ai/l/llms/llama-index-llms-azure-inference)
0 commit comments