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
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ The repo includes sample data so it's ready to try end to end. In this sample ap
74
74
75
75
**IMPORTANT:** In order to deploy and run this example, you'll need:
76
76
77
-
-**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. See [guide to deploying with the free trial](docs/deploy_lowcost.md).
77
+
-**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. See [guide to deploying with the free trial](docs/deploy_freetrial.md).
78
78
-**Azure account permissions**:
79
79
- 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).
80
80
- Your Azure account also needs `Microsoft.Resources/deployments/write` permissions on the subscription level.
@@ -172,7 +172,7 @@ The steps below will provision Azure resources and deploy the application code t
172
172
173
173
Enter a name that will be used for the resource group.
174
174
This will create a new folder in the `.azure` folder, and set it as the active environment for any calls to `azd` going forward.
175
-
1. (Optional) This is the point where you can customize the deployment by setting environment variables, in order to [use existing resources](docs/deploy_existing.md), [enable optional features (such as auth or vision)](docs/deploy_features.md), or [deploy to free tiers](docs/deploy_lowcost.md).
175
+
1. (Optional) This is the point where you can customize the deployment by setting environment variables, in order to [use existing resources](docs/deploy_existing.md), [enable optional features (such as auth or vision)](docs/deploy_features.md), or [deploy low-cost options](docs/deploy_lowcost.md), or [deploy with the Azure free trial](docs/deploy_freetrial.md).
176
176
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.
177
177
- **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.
178
178
- 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.
Copy file name to clipboardExpand all lines: docs/deploy_lowcost.md
+18-5Lines changed: 18 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,24 @@ However, if your goal is to minimize costs while prototyping your application, f
21
21
Enter a name that will be used for the resource group.
22
22
This will create a new folder in the `.azure` folder, and set it as the active environment for any calls to `azd` going forward.
23
23
24
-
1. Use the free tier of App Service:
24
+
1. Switch from Azure Container Apps to the free tier of Azure App Service:
25
25
26
-
```shell
27
-
azd env set AZURE_APP_SERVICE_SKU F1
28
-
```
26
+
Azure Container Apps has a consumption-based pricing model that is very low cost, but it is not free, plus Azure Container Registry costs a small amount each month.
27
+
28
+
To deploy to App Service instead:
29
+
30
+
* Comment out `host: containerapp` and uncomment `host: appservice`in the [azure.yaml](../azure.yaml) file.
31
+
* Set the deployment target to `appservice`:
32
+
33
+
```shell
34
+
azd env set DEPLOYMENT_TARGET appservice
35
+
```
36
+
37
+
* Set the App Service SKU to the free tier:
38
+
39
+
```shell
40
+
azd env set AZURE_APP_SERVICE_SKU F1
41
+
```
29
42
30
43
Limitation: You are only allowed a certain number of free App Service instances per region. If you have exceeded your limit in a region, you will get an error during the provisioning stage. If that happens, you can run `azd down`, then`azd env new` to create a new environment with a new region.
31
44
@@ -88,7 +101,7 @@ However, if your goal is to minimize costs while prototyping your application, f
88
101
Application Insights is quite inexpensive already, so turning this off may not be worth the costs saved,
89
102
but it is an option for those who want to minimize costs.
90
103
91
-
1. Use OpenAI.com instead of Azure OpenAI: This is only a necessary step for Azure free/student accounts, as they do not currently have access to Azure OpenAI.
104
+
1. Use OpenAI.com instead of Azure OpenAI: This should not be necessary, as the costs are same for both services, but you may need this step if your account does not have access to Azure OpenAI for some reason.
# RAG chat: Using GPT vision model with RAG approach
2
2
3
-
This repository now includes an example of integrating a GPT Vision model with Azure AI Search. This feature enables indexing and searching images and graphs, such as financial documents, in addition to text-based content, and then sending the retrieved content to the GPT model for response generation.
3
+
This repository includes an optional feature that uses the GPT vision model to generate responses based on retrieved content. This feature is useful for answering questions based on the visual content of documents, such as photos and charts.
4
4
5
-
## Feature Overview
5
+
## How it works
6
6
7
-
-**Document Handling:** Source documents are split into pages and saved as PNG files in blob storage. Each file's name and page number are embedded for reference.
8
-
-**Data Extraction:** Text data is extracted using OCR.
9
-
-**Data Indexing:** Text and image embeddings, generated using Azure AI Vision ([Azure AI Vision Embeddings](https://learn.microsoft.com/azure/ai-services/computer-vision/how-to/image-retrieval)), are indexed in Azure AI Search along with the raw text.
10
-
-**Search and Response:** Searches can be conducted using vectors or hybrid methods. Responses are generated by GPT vision model based on the retrieved content.
7
+
When this feature is enabled, the following changes are made to the application:
11
8
12
-
## Getting Started
9
+
***Search index**: We added a new field to the Azure AI Search index to store the embedding returned by the multimodal Azure AI Vision API (while keeping the existing field that stores the OpenAI text embeddings).
10
+
***Data ingestion**: In addition to our usual PDF ingestion flow, we also convert each PDF document page to an image, store that image with the filename rendered on top, and add the embedding to the index.
11
+
***Question answering**: We search the index using both the text and multimodal embeddings. We send both the text and the image to gpt-4o, and ask it to answer the question based on both kinds of sources.
12
+
***Citations**: The frontend displays both image sources and text sources, to help users understand how the answer was generated.
13
13
14
-
### Prerequisites
14
+
For more details on how this feature works, read [this blog post](https://techcommunity.microsoft.com/blog/azuredevcommunityblog/integrating-vision-into-rag-applications/4239460) or watch [this video](https://www.youtube.com/live/C3Zq3z4UQm4?si=SSPowBBJoTBKZ9WW&t=89).
15
+
16
+
## Using the feature
15
17
16
-
- Create a [Computer Vision account in Azure Portal first](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesComputerVision), so that you can agree to the Responsible AI terms for that resource. You can delete that account after agreeing.
17
-
- The ability to deploy a gpt-4o model in the [supported regions](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability). If you're not sure, try to create a gpt-4o deployment from your Azure OpenAI deployments page.
18
-
- Ensure that you can deploy the Azure OpenAI resource group in [a region where all required components are available](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability):
19
-
- Azure OpenAI models
20
-
- gpt-35-turbo
21
-
- text-embedding-ada-002
22
-
- gpt-4o
23
-
-[Azure AI Vision](https://learn.microsoft.com/azure/ai-services/computer-vision/)
18
+
### Prerequisites
24
19
25
-
### Setup and Usage
20
+
* Create a [AI Vision account in Azure Portal first](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesComputerVision), so that you can agree to the Responsible AI terms for that resource. You can delete that account after agreeing.
21
+
* The ability to deploy a gpt-4o model in the [supported regions](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability). If you're not sure, try to create a gpt-4o deployment from your Azure OpenAI deployments page.
22
+
* Ensure that you can deploy the Azure OpenAI resource group in [a region where all required components are available](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability):
23
+
* Azure OpenAI models
24
+
* gpt-35-turbo
25
+
* text-embedding-ada-002
26
+
* gpt-4o
27
+
*[Azure AI Vision](https://learn.microsoft.com/azure/ai-services/computer-vision/)
26
28
27
-
1.**Update repository:**
28
-
Pull the latest changes.
29
+
### Deployment
29
30
30
-
2.**Enable GPT vision approach:**
31
+
1.**Enable GPT vision approach:**
31
32
32
33
First, make sure you do *not* have integrated vectorization enabled, since that is currently incompatible:
33
34
@@ -41,19 +42,17 @@ This repository now includes an example of integrating a GPT Vision model with A
41
42
azd env set USE_GPT4V true
42
43
```
43
44
44
-
When set, that flag will provision a Computer Vision resource and gpt-4o model, upload image versions of PDFs to Blob storage, upload embeddings of images in a new `imageEmbedding` field, and enable the vision approach in the UI.
45
+
When set, that flag will provision a Azure AI Vision resource and gpt-4o model, upload image versions of PDFs to Blob storage, upload embeddings of images in a new `imageEmbedding` field, and enable the vision approach in the UI.
45
46
46
-
3.**Clean old deployments (optional):**
47
+
2.**Clean old deployments (optional):**
47
48
Run `azd down --purge` for a fresh setup.
48
49
49
-
4.**Start the application:**
50
+
3.**Start the application:**
50
51
Execute `azd up` to build, provision, deploy, and initiate document preparation.
Copy file name to clipboardExpand all lines: docs/login_and_acl.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,13 +123,14 @@ The following instructions explain how to setup the two apps using the Azure Por
123
123
- In the **Name** section, enter a meaningful application name. This name will be displayed to users of the app, for example `Azure Search OpenAI Chat Web App`.
124
124
- Under **Supported account types**, select **Accounts in this organizational directory only**.
125
125
- Under `Redirect URI (optional)` section, select `Single-page application (SPA)` in the combo-box and enter the following redirect URI:
126
-
- If you are running the sample locally, use `http://localhost:50505/redirect`.
127
-
- If you are running the sample on Azure, use the endpoint provided by `azd up`: `https://<your-endpoint>.azurewebsites.net/redirect`.
128
-
- If you are running the sample from Github Codespaces, use the Codespaces endpoint: `https://<your-codespace>-50505.app.github.dev/`
126
+
- If you are running the sample locally, add the endpoints `http://localhost:50505/redirect` and `http://localhost:5173/redirect`
127
+
- If you are running the sample on Azure, add the endpoints provided by `azd up`: `https://<your-endpoint>.azurewebsites.net/redirect`.
128
+
- If you are running the sample from Github Codespaces, add the Codespaces endpoint: `https://<your-codespace>-50505.app.github.dev/redirect`
129
129
- Select **Register** to create the application
130
130
- In the app's registration screen, find the **Application (client) ID**.
131
131
- Run the following `azd` command to save this ID: `azd env set AZURE_CLIENT_APP_ID <Application (client) ID>`.
132
132
- In the left hand menu, select **Authentication**.
133
+
- Under Web, add a redirect URI with the endpoint provided by `azd up`: `https://<your-endpoint>.azurewebsites.net/.auth/login/aad/callback`.
133
134
- Under **Implicit grant and hybrid flows**, select **ID Tokens (used for implicit and hybrid flows)**
134
135
- Select **Save**
135
136
- In the left hand menu, select **API permissions**. You will add permission to access the **access_as_user** API on the server app. This permission is required for the [On Behalf Of Flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-on-behalf-of-flow#protocol-diagram) to work.
@@ -138,6 +139,11 @@ The following instructions explain how to setup the two apps using the Azure Por
138
139
- Ensure **Delegated permissions** is selected.
139
140
- In the **Select permissions** section, select the **access_as_user** permission
140
141
- Select **Add permissions**.
142
+
- Stay in the **API permissions** section and select **Add a permission**.
143
+
- Select **Microsoft Graph**.
144
+
- Select **Delegated permissions**.
145
+
- Search for and select `User.Read`.
146
+
- Select **Add permissions**.
141
147
142
148
#### Configure Server App Known Client Applications
0 commit comments