Skip to content

Commit 1fc0647

Browse files
authored
Update nuget pkgs, update deploy to use gpt-4o-mini and target region (#358)
## Purpose - update nuget packages to latest versions - change default model from `gpt-35-turbo` to `gpt-4o-mini` - change default azure deployment region to `East US` - remove the paragraph about requesting access to `AOAI` ## Does this introduce a breaking change? <!-- Mark one with an "x". --> ``` [ ] Yes [X] No ``` ## Pull Request Type What kind of change does this Pull Request introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [ ] Bugfix [ ] Feature [ ] Code style update (formatting, local variables) [X] Refactoring (no functional changes, no api changes) [X] Documentation content changes [X] Other: Update deploy to use the latest AOAI GPT model ``` ## How to Test * Get the code ``` git clone [repo-address] cd [repo-name] ``` * Test the code / deploy ``` azd up ```
1 parent d34be17 commit 1fc0647

File tree

3 files changed

+40
-27
lines changed

3 files changed

+40
-27
lines changed

README.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ description: A csharp sample app that chats with your data using OpenAI and AI S
5656
[![Open in GitHub - Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=624102171&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=WestUs2)
5757
[![Open in Remote - Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Remote%20-%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/azure-search-openai-demo-csharp)
5858

59-
This sample demonstrates a few approaches for creating ChatGPT-like experiences over your own data using the Retrieval Augmented Generation pattern. It uses Azure OpenAI Service to access the ChatGPT model (`gpt-35-turbo`), and Azure AI Search for data indexing and retrieval.
59+
This sample demonstrates a few approaches for creating ChatGPT-like experiences over your own data using the Retrieval Augmented Generation pattern. It uses Azure OpenAI Service to access the ChatGPT model (`gpt-4o-mini`), and Azure AI Search for data indexing and retrieval.
6060

6161
The repo includes sample data so it's ready to try end-to-end. In this sample application, we use a fictitious company called Contoso Electronics, and the experience allows its employees to ask questions about the benefits, internal policies, as well as job descriptions and roles.
6262

@@ -94,10 +94,8 @@ We want to hear from you! Are you interested in building or currently building i
9494
In order to deploy and run this example, you'll need
9595

9696
- **Azure Account** - If you're new to Azure, get an [Azure account for free](https://aka.ms/free) and you'll get some free Azure credits to get started.
97-
- **Azure subscription with access enabled for the Azure OpenAI service** - [You can request access](https://aka.ms/oaiapply). You can also visit [the Azure AI Search docs](https://azure.microsoft.com/free/cognitive-search/) to get some free Azure credits to get you started.
9897
- **Azure account permissions** - Your Azure Account must have `Microsoft.Authorization/roleAssignments/write` permissions, such as [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).
9998

100-
10199
> [!WARNING]<br>
102100
> By default this sample will create an Azure Container App, and Azure AI Search resource that have a monthly cost, as well as Form Recognizer resource that has cost per document page. You can switch them to free versions of each of them if you want to avoid this cost by changing the parameters file under the infra folder (though there are some limits to consider; for example, you can have up to 1 free Azure AI Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document.)
103101
@@ -126,12 +124,12 @@ Install the following prerequisites:
126124
- [Git](https://git-scm.com/downloads)
127125
- [Powershell 7+ (pwsh)](https://github.com/powershell/powershell) - For Windows users only.
128126

129-
> **Important**<br>
127+
> **Important**:
130128
> Ensure you can run `pwsh.exe` from a PowerShell command. If this fails, you likely need to upgrade PowerShell.
131129
132130
- [Docker](https://www.docker.com/products/docker-desktop/)
133131

134-
> **Important**<br>
132+
> **Important**:
135133
> Ensure Docker is running before running any `azd` provisioning / deployment commands.
136134
137135
Then, run the following commands to get the project on your local environment:
@@ -144,26 +142,29 @@ Then, run the following commands to get the project on your local environment:
144142

145143
#### Deploying from scratch
146144

147-
> **Important**<br>
145+
[📺 Live stream: Deploying from scratch](https://youtu.be/wgSnkxGH2Sk?si=C4zAbLKhK3LoAS43)
146+
147+
> **Important**:
148148
> Ensure Docker is running before running any `azd` provisioning / deployment commands.
149149
150150
Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.
151151

152152
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.
153-
- For the target location, the regions that currently support the model used in this sample are **East US 2** , **East US** or **South Central US**. For an up-to-date list of regions and models, check [here](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models)
153+
- For the target location, the regions that currently support the model used in this sample are **East US** or **Sweden Central**. For an up-to-date list of regions and models, check [here](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models)
154154
- If you have access to multiple Azure subscriptions, you will be prompted to select the subscription you want to use. If you only have access to one subscription, it will be selected automatically.
155155

156-
> **Note**<br>
157-
> This application uses the `gpt-35-turbo` model. When choosing which region to deploy to, make sure they're available in that region (i.e. EastUS). For more information, see the [Azure OpenAI Service documentation](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#gpt-35-models).
156+
> **Note**:
157+
> This application uses the `gpt-4o-mini` model. When choosing which region to deploy to, make sure they're available in that region (i.e. EastUS). For more information, see the [Azure OpenAI Service documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#standard-deployment-model-availability).
158158
159159
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.
160160

161161
It will look like the following:
162162

163163
!['Output from running azd up'](assets/endpoint.png)
164164

165-
> [!NOTE]<br>
165+
> [!NOTE]:
166166
> It may take a few minutes for the application to be fully deployed.
167+
> After the application is deployed, it will also take a few minutes to process the documents to be added into the vector database.
167168
168169
#### Use existing resources
169170

@@ -298,21 +299,23 @@ To then limit access to a specific set of users or groups, you can follow the st
298299

299300
### Enable vision (multi-modal) support
300301

301-
With GPT-4o, it's possible to support an enrichmented retrival augmented generation by providing both text and image as source content. To enable vision support, you need to enable `USE_VISION` and use `GPT-4o` model when provisioning.
302+
With `GPT-4o-mini`, it's possible to support an enrichmented retrival augmented generation by providing both text and image as source content. To enable vision support, you need to enable `USE_VISION` and use `GPT-4o` or `GPT-4o-mini` model when provisioning.
302303

303304
> [!NOTE]
304305
> You would need to re-indexing supporting material and re-deploy the application after enabling GPT-4o support if you have already deployed the application before. This is because enabling GPT-4o support requires new fields to be added to the search index.
305306
306307
To enable GPT-4V support with Azure OpenAI Service, run the following commands:
308+
307309
```bash
308310
azd env set USE_VISION true
309311
azd env set USE_AOAI true
310-
azd env set AZURE_OPENAI_CHATGPT_MODEL_NAME gpt-4o
311-
azd env set AZURE_OPENAI_RESOURCE_LOCATION westus # Please check the gpt-4o availability for more details.
312+
azd env set AZURE_OPENAI_CHATGPT_MODEL_NAME gpt-4o-mini
313+
azd env set AZURE_OPENAI_RESOURCE_LOCATION eastus # Please check the gpt model availability for more details.
312314
azd up
313315
```
314316

315317
To enable vision support with OpenAI, run the following commands:
318+
316319
```bash
317320
azd env set USE_VISION true
318321
azd env set USE_AOAI false
@@ -321,23 +324,31 @@ azd up
321324
```
322325

323326
To clean up previously deployed resources, run the following command:
327+
324328
```bash
325329
azd down --purge
326330
azd env set AZD_PREPDOCS_RAN false # This is to ensure that the documents are re-indexed with the new fields.
327331
```
332+
328333
## Productionizing
329334

330335
This sample is designed to be a starting point for your own production application,
331336
but you should do a thorough review of the security and performance before deploying
332337
to production. Here are some things to consider:
333338

334-
* **OpenAI Capacity**: The default TPM (tokens per minute) is set to 30K. That is equivalent to approximately 30 conversations per minute (assuming 1K per user message/response). You can increase the capacity by changing the `chatGptDeploymentCapacity` and `embeddingDeploymentCapacity` parameters in `infra/main.bicep` to your account's maximum capacity. You can also view the Quotas tab in [Azure OpenAI studio](https://oai.azure.com/) to understand how much capacity you have.
335-
* **Azure Storage**: The default storage account uses the `Standard_LRS` SKU. To improve your resiliency, we recommend using `Standard_ZRS` for production deployments, which you can specify using the `sku` property under the `storage` module in `infra/main.bicep`.
336-
* **Azure AI Search**: If you see errors about search service capacity being exceeded, you may find it helpful to increase the number of replicas by changing `replicaCount` in `infra/core/search/search-services.bicep` or manually scaling it from the Azure Portal.
337-
* **Azure Container Apps**: By default, this application deploys containers with 0.5 CPU Cores and 1GB of memory. The minimum replicas is 1 and maximum 10. For this app, you can set values such as `containerCpuCoreCount`, `containerMaxReplicas `, `containerMemory`, `containerMinReplicas` in the `infra/core/host/container-app.bicep` file to fit your needs. You can use auto-scaling rules or scheduled scaling rules, and scale up the [maximum/minimum](https://learn.microsoft.com/azure/container-apps/scale-app) based on load.
338-
* **Authentication**: By default, the deployed app is publicly accessible. We recommend restricting access to authenticated users. See [Enabling authentication](#enabling-authentication) above for how to enable authentication.
339-
* **Networking**: We recommend deploying inside a Virtual Network. If the app is only for internal enterprise use, use a private DNS zone. Also consider using Azure API Management (APIM) for firewalls and other forms of protection. For more details, read [Azure OpenAI Landing Zone reference architecture](https://techcommunity.microsoft.com/t5/azure-architecture-blog/azure-openai-landing-zone-reference-architecture/ba-p/3882102).
340-
* **Loadtesting**: We recommend running a loadtest for your expected number of users.
339+
- **OpenAI Capacity**: The default TPM (tokens per minute) is set to 30K. That is equivalent to approximately 30 conversations per minute (assuming 1K per user message/response). You can increase the capacity by changing the `chatGptDeploymentCapacity` and `embeddingDeploymentCapacity` parameters in `infra/main.bicep` to your account's maximum capacity. You can also view the Quotas tab in [Azure OpenAI studio](https://oai.azure.com/) to understand how much capacity you have.
340+
341+
- **Azure Storage**: The default storage account uses the `Standard_LRS` SKU. To improve your resiliency, we recommend using `Standard_ZRS` for production deployments, which you can specify using the `sku` property under the `storage` module in `infra/main.bicep`.
342+
343+
- **Azure AI Search**: If you see errors about search service capacity being exceeded, you may find it helpful to increase the number of replicas by changing `replicaCount` in `infra/core/search/search-services.bicep` or manually scaling it from the Azure Portal.
344+
345+
- **Azure Container Apps**: By default, this application deploys containers with 0.5 CPU Cores and 1GB of memory. The minimum replicas is 1 and maximum 10. For this app, you can set values such as `containerCpuCoreCount`, `containerMaxReplicas `, `containerMemory`, `containerMinReplicas` in the `infra/core/host/container-app.bicep` file to fit your needs. You can use auto-scaling rules or scheduled scaling rules, and scale up the [maximum/minimum](https://learn.microsoft.com/azure/container-apps/scale-app) based on load.
346+
347+
- **Authentication**: By default, the deployed app is publicly accessible. We recommend restricting access to authenticated users. See [Enabling authentication](#enabling-authentication) above for how to enable authentication.
348+
349+
- **Networking**: We recommend deploying inside a Virtual Network. If the app is only for internal enterprise use, use a private DNS zone. Also consider using Azure API Management (APIM) for firewalls and other forms of protection. For more details, read [Azure OpenAI Landing Zone reference architecture](https://techcommunity.microsoft.com/t5/azure-architecture-blog/azure-openai-landing-zone-reference-architecture/ba-p/3882102).
350+
351+
- **Loadtesting**: We recommend running a loadtest for your expected number of users.
341352

342353
## Guidance
343354

@@ -367,4 +378,4 @@ Pricing varies per region and usage, so it isn't possible to predict exact costs
367378

368379
**_Question_**: Why do we need to break up the PDFs into chunks when Azure AI Search supports searching large documents?
369380

370-
**_Answer_**: Chunking allows us to limit the amount of information we send to OpenAI due to token limits. By breaking up the content, it allows us to easily find potential chunks of text that we can inject into OpenAI. The method of chunking we use leverages a sliding window of text such that sentences that end one chunk will start the next. This allows us to reduce the chance of losing the context of the text.
381+
**_Answer_**: Chunking allows us to limit the amount of information we send to OpenAI due to token limits. By breaking up the content, it allows us to easily find potential chunks of text that we can inject into OpenAI. The method of chunking we use leverages a sliding window of text such that sentences that end one chunk will start the next. This allows us to reduce the chance of losing the context of the text.

infra/main.bicep

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ param openAiResourceGroupLocation string
2121

2222
@description('Name of the chat GPT model. Default: gpt-35-turbo')
2323
@allowed([ 'gpt-35-turbo', 'gpt-4', 'gpt-4o', 'gpt-4o-mini', 'gpt-35-turbo-16k', 'gpt-4-16k' ])
24-
param azureOpenAIChatGptModelName string = 'gpt-35-turbo'
24+
param azureOpenAIChatGptModelName string = 'gpt-4o-mini'
2525

26-
param azureOpenAIChatGptModelVersion string ='0613'
26+
@description('Name of the chat GPT model. Default: 0613 for gpt-35-turbo, or choose 2024-07-18 for gpt-4o-mini')
27+
@allowed([ '0613', '2024-07-18' ])
28+
param azureOpenAIChatGptModelVersion string ='2024-07-18'
2729

2830
@description('Name of the Azure Application Insights dashboard')
2931
param applicationInsightsDashboardName string = ''
@@ -35,7 +37,7 @@ param applicationInsightsName string = ''
3537
param appServicePlanName string = ''
3638

3739
@description('Capacity of the chat GPT deployment. Default: 10')
38-
param chatGptDeploymentCapacity int = 10
40+
param chatGptDeploymentCapacity int = 8
3941

4042
@description('Name of the chat GPT deployment')
4143
param azureChatGptDeploymentName string = 'chat'

infra/main.parameters.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@
9090
"value": "${USE_VISION=false}"
9191
},
9292
"openAiChatGptDeployment": {
93-
"value": "${OPENAI_CHATGPT_DEPLOYMENT=gpt-3.5-turbo}"
93+
"value": "${OPENAI_CHATGPT_DEPLOYMENT=gpt-4o-mini}"
9494
},
9595
"openAiEmbeddingDeployment": {
9696
"value": "${OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-ada-002}"
9797
},
9898
"azureOpenAIChatGptModelVersion": {
99-
"value": "${AZURE_OPENAI_CHATGPT_MODEL_VERSION=0613}"
99+
"value": "${AZURE_OPENAI_CHATGPT_MODEL_VERSION=2024-07-18}"
100100
},
101101
"azureOpenAIChatGptModelName": {
102-
"value": "${AZURE_OPENAI_CHATGPT_MODEL_NAME=gpt-35-turbo}"
102+
"value": "${AZURE_OPENAI_CHATGPT_MODEL_NAME=gpt-4o-mini}"
103103
},
104104
"azureOpenAIChatGptDeploymentCapacity": {
105105
"value": "${AZURE_OPENAI_CHATGPT_DEPLOYMENT_CAPACITY=30}"

0 commit comments

Comments
 (0)