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: README.md
+47-27Lines changed: 47 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,10 @@ This template, the application code and configuration it contains, has been buil
31
31
32
32
## Table of Contents
33
33
34
+
-[LlamaIndex RAG chat app with Azure OpenAI and Azure AI Search (JavaScript)](#llamaindex-rag-chat-app-with-azure-openai-and-azure-ai-search-javascript)
@@ -58,7 +63,7 @@ The repo includes sample data so it's ready to try end to end. In this sample ap
58
63
59
64
-**Azure account**. If you're new to Azure, [get an Azure account for free](https://azure.microsoft.com/free/cognitive-search/) and you'll get some free Azure credits to get started.
60
65
-**Azure account permissions**:
61
-
- Your Azure account must have `Microsoft.Authorization/roleAssignments/write` permissions, such as [Role Based Access Control Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview), [User Access Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#user-access-administrator), or [Owner](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#owner). If you don't have subscription-level permissions, you must be granted [RBAC](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview) for an existing resource group and [deploy to that existing group](docs/deploy_existing.md#resource-group).
66
+
- Your Azure account must have `Microsoft.Authorization/roleAssignments/write` permissions, such as [Role Based Access Control Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview), [User Access Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#user-access-administrator), or [Owner](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#owner). If you don't have subscription-level permissions, you must be granted [RBAC](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview) for an existing resource group and deploy to that existing group.
62
67
- Your Azure account also needs `Microsoft.Resources/deployments/write` permissions on the subscription level.
63
68
64
69
### Cost estimation
@@ -67,14 +72,14 @@ Pricing varies per region and usage, so it isn't possible to predict exact costs
67
72
However, you can try the [Azure pricing calculator](https://azure.com/e/a87a169b256e43c089015fda8182ca87) for the resources below.
68
73
69
74
* Azure Container Apps: Consumption plan with 1 CPU core, 2.0 GB RAM. Pricing with Pay-as-You-Go. [Pricing](https://azure.microsoft.com/pricing/details/container-apps/)
70
-
* Azure OpenAI: Standard tier, gpt-4 and text-embedding-3-large models. Pricing per 1K tokens used. [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
75
+
* Azure OpenAI: Standard tier, gpt-4o-mini and text-embedding-3-large models. Pricing per 1K tokens used. [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)
71
76
* Azure AI Search: Standard tier, 1 replica, free level of semantic search. Pricing per hour. [Pricing](https://azure.microsoft.com/pricing/details/search/)
72
77
* Azure Blob Storage: Standard tier with ZRS (Zone-redundant storage). Pricing per storage and read operations. [Pricing](https://azure.microsoft.com/pricing/details/storage/blobs/)
73
78
* Azure Monitor: Pay-as-you-go tier. Costs based on data ingested. [Pricing](https://azure.microsoft.com/pricing/details/monitor/)
74
79
75
80
To reduce costs, you can switch to free SKUs for various services, but those SKUs have limitations.
76
81
77
-
To avoid unnecessary costs, remember to take down your app if it's no longer in use,
82
+
To avoid unnecessary costs, remember to take down your app if it's no longer in use,
78
83
either by deleting the resource group in the Portal or running `azd down`.
79
84
80
85
## Getting Started
@@ -114,46 +119,61 @@ A related option is VS Code Dev Containers, which will open the project in your
114
119
2. Create a new folder and switch to it in the terminal.
115
120
3. Run this command to download the project code:
116
121
117
-
```shell
118
-
azd init -t llamaindex-search-javascript
119
-
```
122
+
```shell
123
+
azd init -t llamaindex-search-javascript
124
+
```
120
125
121
-
Note that this command will initialize a git repository, so you do not need to clone this repository.
126
+
> [!NOTE]
127
+
> This command will initialize a git repository, so you do not need to clone this repository.
122
128
123
129
## Deploying
124
130
125
131
The steps below will provision Azure resources and deploy the application code to Azure Container Apps.
126
132
127
-
1. Login to your Azure account:
133
+
Login to your Azure account:
128
134
129
-
```shell
130
-
azd auth login
131
-
```
135
+
```shell
136
+
azd auth login
137
+
```
132
138
133
-
For GitHub Codespaces users, if the previous command fails, try:
139
+
For GitHub Codespaces users, if the previous command fails, try:
134
140
135
-
```shell
136
-
azd auth login --use-device-code
137
-
```
141
+
```shell
142
+
azd auth login --use-device-code
143
+
```
144
+
145
+
Create a new azd environment:
138
146
139
-
1. Create a new azd environment:
147
+
```shell
148
+
azd env new
149
+
```
140
150
141
-
```shell
142
-
azd env new
143
-
```
151
+
Enter a name that will be used for the resource group.
152
+
This will create a new folder in the `.azure` folder, and set it as the active environment for any calls to `azd` going forward.
144
153
145
-
Enter a name that will be used for the resource group.
146
-
This will create a new folder in the `.azure` folder, and set it as the active environment for any calls to `azd` going forward.
147
-
1. Run `azd up` - This will provision Azure resources and deploy this sample to those resources, including building the search index based on the files found in the `./data` folder.
148
-
- **Important**: Beware that the resources created by this command will incur immediate costs, primarily from the AI Search resource. These resources may accrue costs even if you interrupt the command before it is fully executed. You can run `azd down` or delete the resources manually to avoid unnecessary spending.
149
-
- You will be prompted to selecttwo locations, one for the majority of resources and one for the OpenAI resource, which is currently a short list. That location list is based on the [OpenAI model availability table](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability) and may become outdated as availability changes.
150
-
1. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.
154
+
Package, provision and deploy this project to Azure:
155
+
156
+
```shell
157
+
azd up
158
+
```
159
+
160
+
> [!NOTE]
161
+
> This will provision Azure resources and deploy this sample to those resources, including building the search index based on the files found in the ./data folder.
162
+
163
+
After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.
151
164
152
165
It will look like the following:
153
166
154
167

155
168
156
-
> NOTE: It may take 5-10 minutes after you see 'SUCCESS'for the application to be fully deployed.
169
+
> [!NOTE]
170
+
> It may take 5-10 minutes after you see 'SUCCESS' for the application to be fully deployed.
171
+
172
+
> [!IMPORTANT]
173
+
> Beware that the resources created by this command will incur immediate costs, primarily from the AI Search resource. These resources may accrue costs even if you interrupt the command before it is fully executed. You can run `azd down` or delete the resources manually to avoid unnecessary spending.
174
+
>
175
+
> You will be prompted to select two locations, one for the majority of resources and one for the OpenAI resource, which is currently a short list. That location list is based on the [OpenAI model availability table](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability) and may become outdated as availability changes.
176
+
157
177
158
178
### Deploying again
159
179
@@ -248,7 +268,7 @@ NOTE: you can also run `azd down --purge --force`.
248
268
249
269
The resource group and all the resources will be deleted.
250
270
251
-
# Guidance
271
+
##Guidance
252
272
253
273
You can find extensive documentation in the [docs](docs/README.md) folder:
-[Adding an OpenAI load balancer](#adding-an-openai-load-balancer)
11
12
12
13
## Using GPT-4
13
14
@@ -19,73 +20,73 @@ Execute the following commands inside your terminal:
19
20
20
21
1. To set the name of the deployment, run this command with a unique name in your Azure OpenAI account. You can use any deployment name, as long as it's unique in your Azure OpenAI account.
21
22
22
-
```bash
23
-
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT <your-deployment-name>
24
-
```
23
+
```bash
24
+
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT <your-deployment-name>
25
+
```
25
26
26
-
For example:
27
+
For example:
27
28
28
-
```bash
29
-
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT chat4
30
-
```
29
+
```bash
30
+
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT chat4
31
+
```
31
32
32
33
1. To set the GPT model name to a **gpt-4**, **gpt-4o**, or **gpt-4o mini** version from the [available models](https://learn.microsoft.com/azure/ai-services/openai/concepts/models), run this command with the appropriate GPT model name.
33
34
34
-
For GPT-4:
35
+
For GPT-4:
35
36
36
-
```bash
37
-
azd env set AZURE_OPENAI_CHATGPT_MODEL gpt-4
38
-
```
37
+
```bash
38
+
azd env set AZURE_OPENAI_CHATGPT_MODEL gpt-4
39
+
```
39
40
40
-
For GPT-4o:
41
+
For GPT-4o:
41
42
42
-
```bash
43
-
azd env set AZURE_OPENAI_CHATGPT_MODEL gpt-4o
44
-
```
43
+
```bash
44
+
azd env set AZURE_OPENAI_CHATGPT_MODEL gpt-4o
45
+
```
45
46
46
-
For GPT-4o mini:
47
+
For GPT-4o mini:
47
48
48
-
```bash
49
-
azd env set AZURE_OPENAI_CHATGPT_MODEL gpt-4o-mini
50
-
```
49
+
```bash
50
+
azd env set AZURE_OPENAI_CHATGPT_MODEL gpt-4o-mini
51
+
```
51
52
52
53
1. To set the Azure OpenAI deployment SKU name, run this command with [the desired SKU name](https://learn.microsoft.com/azure/ai-services/openai/how-to/deployment-types#deployment-types).
53
54
54
-
```bash
55
-
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_SKU GlobalStandard
56
-
```
55
+
```bash
56
+
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_SKU GlobalStandard
57
+
```
57
58
58
59
1. To set the Azure OpenAI deployment capacity, run this command with the desired capacity.
59
60
60
-
```bash
61
-
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_CAPACITY 10
62
-
```
61
+
```bash
62
+
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_CAPACITY 10
63
+
```
63
64
64
65
1. To set the Azure OpenAI deployment version from the [available versions](https://learn.microsoft.com/azure/ai-services/openai/concepts/models), run this command with the appropriate version.
65
66
66
-
For GPT-4:
67
+
For GPT-4:
67
68
68
-
```bash
69
-
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_VERSION turbo-2024-04-09
70
-
```
69
+
```bash
70
+
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_VERSION turbo-2024-04-09
71
+
```
71
72
72
-
For GPT-4o:
73
+
For GPT-4o:
73
74
74
-
```bash
75
-
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_VERSION 2024-05-13
76
-
```
75
+
```bash
76
+
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_VERSION 2024-05-13
77
+
```
77
78
78
-
For GPT-4o mini:
79
+
For GPT-4o mini:
79
80
80
-
```bash
81
-
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_VERSION 2024-07-18
82
-
```
81
+
```bash
82
+
azd env set AZURE_OPENAI_CHAT_DEPLOYMENT_VERSION 2024-07-18
83
+
```
83
84
84
85
1. To update the deployment with the new parameters, run this command.
85
86
86
-
```bash
87
-
azd up
88
-
```
87
+
```bash
88
+
azd up
89
+
```
89
90
90
91
> [!NOTE]
91
92
> To revert back to GPT 3.5, run the following commands:
@@ -105,25 +106,25 @@ By default, the deployed Azure web app uses the `text-embedding-ada-002` embeddi
105
106
106
107
1. Run one of the following commands to set the desired model:
107
108
108
-
```shell
109
-
azd env set AZURE_OPENAI_EMB_MODEL_NAME text-embedding-3-small
110
-
```
109
+
```shell
110
+
azd env set AZURE_OPENAI_EMB_MODEL_NAME text-embedding-3-small
111
+
```
111
112
112
-
```shell
113
-
azd env set AZURE_OPENAI_EMB_MODEL_NAME text-embedding-3-large
114
-
```
113
+
```shell
114
+
azd env set AZURE_OPENAI_EMB_MODEL_NAME text-embedding-3-large
115
+
```
115
116
116
117
2. Specify the desired dimensions of the model: (from 256-3072, model dependent)
117
118
118
-
```shell
119
-
azd env set AZURE_OPENAI_EMB_DIMENSIONS 256
120
-
```
119
+
```shell
120
+
azd env set AZURE_OPENAI_EMB_DIMENSIONS 256
121
+
```
121
122
122
123
3. Set the model version to "1" (the only version as of March 2024):
123
124
124
-
```shell
125
-
azd env set AZURE_OPENAI_EMB_DEPLOYMENT_VERSION 1
126
-
```
125
+
```shell
126
+
azd env set AZURE_OPENAI_EMB_DEPLOYMENT_VERSION 1
127
+
```
127
128
128
129
4. When prompted during `azd up`, make sure to select a region for the OpenAI resource group location that supports the text-embedding-3 models. There are [limited regions available](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#embeddings-models).
129
130
@@ -143,5 +144,5 @@ To then limit access to a specific set of users or groups, you can follow the st
143
144
144
145
## Adding an OpenAI load balancer
145
146
146
-
As discussed in more details in our [productionizing guide](./productionizing.md), you may want to consider implementing a load balancer between OpenAI instances if you are consistently going over the TPM limit.
147
+
As discussed in more details in our [productionizing guide](./prod.md), you may want to consider implementing a load balancer between OpenAI instances if you are consistently going over the TPM limit.
147
148
Fortunately, this repository is designed for easy integration with other repositories that create load balancers for OpenAI instances.
0 commit comments