diff --git a/.env.sample b/.env.sample index d1ae14e18..52c09f7cb 100644 --- a/.env.sample +++ b/.env.sample @@ -21,6 +21,7 @@ AZURE_OPENAI_TEMPLATE_SYSTEM_MESSAGE="Generate a template for a document given a AZURE_OPENAI_GENERATE_SECTION_CONTENT_PROMPT="Help the user generate content for a section in a document. The user has provided a section title and a brief description of the section. The user would like you to provide an initial draft for the content in the section. Must be less than 2000 characters. Only include the section content, not the title. Do not use markdown syntax. Whenever possible, use ingested documents to help generate the section content." AZURE_OPENAI_TITLE_PROMPT="Summarize the conversation so far into a 4-word or less title. Do not use any quotation marks or punctuation. Respond with a json object in the format {{\"title\": string}}. Do not include any other commentary or description." AZURE_OPENAI_PREVIEW_API_VERSION=2024-05-01-preview +AZURE_OPENAI_API_VERSION=2024-05-01-preview AZURE_OPENAI_STREAM=True AZURE_OPENAI_ENDPOINT= AZURE_OPENAI_EMBEDDING_NAME= diff --git a/README_azd.md b/README_azd.md deleted file mode 100644 index c78286ae5..000000000 --- a/README_azd.md +++ /dev/null @@ -1,73 +0,0 @@ -# (Preview) Sample Chat App with AOAI - -## Deploying with the Azure Developer CLI - -> **IMPORTANT:** In order to deploy and run this example, you'll need an **Azure subscription with access enabled for the Azure OpenAI service**. You can request access [here](https://aka.ms/oaiapply). You can also visit [here](https://azure.microsoft.com/free/cognitive-search/) to get some free Azure credits to get you started. 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). - -> **AZURE RESOURCE COSTS** by default this sample will create Azure App Service and Azure Cognitive Search resources 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 Cognitive Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document.) - -## Opening the project - -This project has [Dev Container support](https://code.visualstudio.com/docs/devcontainers/containers), so it will be be setup automatically if you open it in Github Codespaces or in local VS Code with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). - -If you're not using one of those options for opening the project, then you'll need to: - -1. Install prerequisites: - - - [Azure Developer CLI](https://aka.ms/azure-dev/install) - - [Python 3+](https://www.python.org/downloads/) - - **Important**: Python and the pip package manager must be in the path in Windows for the setup scripts to work. - - [Node.js](https://nodejs.org/en/download/) - - [Git](https://git-scm.com/downloads) - - [Powershell 7+ (pwsh)](https://github.com/powershell/powershell) - For Windows users only. - - **Important**: Ensure you can run `pwsh.exe` from a PowerShell command. If this fails, you likely need to upgrade PowerShell. - - -### Deploying from scratch: - -If you don't have any pre-existing Azure services (i.e. OpenAI or Cognitive Search service), then you can provision -all resources from scratch by following these steps: - -1. Run `azd auth login` to login to your Azure account. -1. Run `azd up` to provision Azure resources and deploy this sample to those resources. This also runs a script to build the search index based on files in the `./data` folder. - * For the target location, the regions that currently support the models used in this sample are **East US** or **South Central US**. For an up-to-date list of regions and models, check [here](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models) -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. - > NOTE: It may take a minute for the application to be fully deployed. If you see a "Python Developer" welcome screen, then wait a minute and refresh the page. - -### Using existing resources: - -If you have existing Azure resources that you want to reuse, then you must first set `azd` environment variables _before_ running `azd up`. - -Run the following commands based on what you want to customize: - -* `azd env set AZURE_OPENAI_RESOURCE {Name of existing OpenAI service}` -* `azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}` -* `azd env set AZURE_OPENAI_SKU_NAME {Name of OpenAI SKU}`. Defaults to 'S0'. -* `azd env set AZURE_SEARCH_SERVICE {Name of existing Cognitive Search service}` -* `azd env set AZURE_SEARCH_SERVICE_RESOURCE_GROUP {Name of existing resource group that Cognitive Search service is provisioned to}` -* `azd env set AZURE_SEARCH_SKU_NAME {Name of Cognitive Search SKY}`. Defaults to 'standard'. -* `azd env set AZURE_FORMRECOGNIZER_SERVICE {Name of existing Form Recognizer service}`. Used by prepdocs.py for text extraction from docs. -* `azd env set AZURE_FORMRECOGNIZER_SERVICE_RESOURCE_GROUP {Name of existing resource group that Form Recognizer service is provisioned to}`. -* `azd env set AZURE_FORMRECOGNIZER_SKU_NAME {Name of Form Recognizer SKU}`. Defaults to 'S0'. - -1. Run `azd auth login` to login to your Azure account. -1. Run `azd up` to provision Azure resources and deploy this sample to those resources. This also runs a script to build the search index based on files in the `./data` folder. -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. - > NOTE: It may take a minute for the application to be fully deployed. If you see a "Python Developer" welcome screen, then wait a minute and refresh the page. - - -### Re-deploying changes - -If you make any changes to the app code (JS or Python), you can re-deploy the app code to App Service by running the `azd deploy` command. - -If you change any of the Bicep files in the infra folder, then you should re-run `azd up` to both provision resources and deploy code. - -### Running locally: - -1. Run `azd auth login` -2. Run `./start.cmd` or `./start.sh` to start the project locally. -3. Navigate to `http://127.0.0.1:5000` in your browser. The deployed code requires authentication, but the local app should allow access as long as it's access from `127.0.0.1`. - -### Note - ->Note: The PDF documents used in this demo contain information generated using a language model (Azure OpenAI Service). The information contained in these documents is only for demonstration purposes and does not reflect the opinions or beliefs of Microsoft. Microsoft makes no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information contained in this document. All rights reserved to Microsoft. diff --git a/infra/deploy_ai_foundry.bicep b/infra/deploy_ai_foundry.bicep index c13365c48..ad75f7127 100644 --- a/infra/deploy_ai_foundry.bicep +++ b/infra/deploy_ai_foundry.bicep @@ -112,6 +112,7 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2021-10-01' = { } kind: 'AIServices' properties: { + customSubDomainName: aiServicesName apiProperties: { statisticsEnabled: false } diff --git a/infra/deploy_app_service.bicep b/infra/deploy_app_service.bicep index 1756040bf..86c6daffa 100644 --- a/infra/deploy_app_service.bicep +++ b/infra/deploy_app_service.bicep @@ -101,7 +101,7 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = { value: azureOpenAIApiVersion } { - name: 'AZURE_OPENAI_DEPLOYMENT_NAME' + name: 'AZURE_OPENAI_MODEL' value: AzureOpenAIModel } { @@ -109,7 +109,7 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = { value: AzureOpenAIEndpoint } { - name: 'AZURE_OPENAI_API_KEY' + name: 'AZURE_OPENAI_KEY' value: AzureOpenAIKey } { diff --git a/infra/main.json b/infra/main.json index 93f6b6d95..88871b620 100644 --- a/infra/main.json +++ b/infra/main.json @@ -5,7 +5,7 @@ "_generator": { "name": "bicep", "version": "0.33.93.31351", - "templateHash": "8931514270414510226" + "templateHash": "3126173092886008904" } }, "parameters": { @@ -380,7 +380,7 @@ "_generator": { "name": "bicep", "version": "0.33.93.31351", - "templateHash": "6139170564292952532" + "templateHash": "14703493169474623961" } }, "parameters": { @@ -563,6 +563,7 @@ }, "kind": "AIServices", "properties": { + "customSubDomainName": "[variables('aiServicesName')]", "apiProperties": { "statisticsEnabled": false } @@ -1181,7 +1182,7 @@ "_generator": { "name": "bicep", "version": "0.33.93.31351", - "templateHash": "13134513664140996267" + "templateHash": "10772344907596853045" } }, "parameters": { @@ -1361,7 +1362,7 @@ "value": "[parameters('azureOpenAIApiVersion')]" }, { - "name": "AZURE_OPENAI_DEPLOYMENT_NAME", + "name": "AZURE_OPENAI_MODEL", "value": "[parameters('AzureOpenAIModel')]" }, { @@ -1369,7 +1370,7 @@ "value": "[parameters('AzureOpenAIEndpoint')]" }, { - "name": "AZURE_OPENAI_API_KEY", + "name": "AZURE_OPENAI_KEY", "value": "[parameters('AzureOpenAIKey')]" }, {