This demonstration allows for a web based playground of Azure Open AI to demonstrate prompt engineering and a few complex workflows. These include
- Open Box Connected Directly to Azure Open AI
- Text Summarization
- Text Comparison
- Resume Search Workflow (under construction)
This workflow is not intended to replace or replicate HR needs or other more complex systems. Instead show a window into how Azure Open AI can be used for human like text analysis.
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.)
Note: Enterprise Security is not a part of this demonstration. Security for the deploy application is controlled by API Keys and System Assigned Identities. Further security demonstrations are available at https://github.com/Azure-Samples
The
.azure/{enviroment-name}/.env
file contains all keys and environmental variables needed to run the demo
To install this on an azure cloud you will need the following
- An Azure Cloud Account with the contributor role to the subscription
- Your Azure Account must have
Microsoft.Authorization/roleAssignments/write
permissions, such as User Access Administrator or Owner.
The demo can be installed from
- Github Codespace
- Docker Container
- Azure Cloud Shell
- A Local Development Machine
To control the resource group that the demo deploys to run
azd env set AZURE_RESOURCE_GROUP {Name of the target resource group}
after runningazd init
. Otherwise the target resource group will berg-{enviroment-name}
To use a preconfigured VM image choose one of the below options.
You may need to give execute authority to the
./scripts
folder with the containers and the cloud accounts or if running from a linux machine.
To install from these cloud development environments open a terminal window
- Run
azd auth login
and follow the instructions. - Run
azd init -t Patrick-Davis-MSFT/AOAI-Prompt-Demo
- Add the
AZURE_OPENAI_RESOURCE_GROUP
andAZURE_OPENAI_SERVICE
to the.azure/{enviroment-name}/.env
fileazd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}
azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
- If running on a linux VM set all scripts in the
scripts
folder to execute usingchmod -R 777 scripts
- Run
azd deploy
- This will create the deployment in a resource group
rg-{enviroment-name}
- This will create the deployment in a resource group
To install from the Azure Cloud Shell
- Create a new directory for the deployment
- You will need to login using
azd auth login
to run the python scripts azd init -t Patrick-Davis-MSFT/AOAI-Prompt-Demo
Note: This will not link the downloaded solution to the git repo- Choose to overwrite the files if no if you cloned and/or made changes locally
- Add the
AZURE_OPENAI_RESOURCE_GROUP
andAZURE_OPENAI_SERVICE
to the.azure/{enviroment-name}/.env
fileazd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}
azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
- Update the other parameters in the
.azure
folder as needed - If running on the Cloud shell set all scripts in the
scripts
folder to execute usingchmod -R 777 scripts
- Deploy the files with
azd up
- Azure Developer CLI
- Python 3+
- Important: Python and the pip package manager must be in the path in Windows for the setup scripts to work.
- Important: Ensure you can run
python --version
from console. On Ubuntu, you might need to runsudo apt install python-is-python3
to linkpython
topython3
.
- Node.js
- Git
- Powershell 7+ (pwsh) - For Windows users only.
- Important: Ensure you can run
pwsh.exe
from a PowerShell command. If this fails, you likely need to upgrade PowerShell.
- Important: Ensure you can run
- Optional: Visual Studio Code
- Create a new folder and switch to it in the terminal
- Run
azd auth login
- Run
azd init -t Patrick-Davis-MSFT/AOAI-Prompt-Demo
- note that this command will download this repository but will not initialize git to track local changes
- Add the
AZURE_OPENAI_RESOURCE_GROUP
andAZURE_OPENAI_SERVICE
to the.azure/{enviroment-name}/.env
file by running the followingazd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}
azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
- 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.- For the target location, the regions that currently support the models used in this sample are East US, France Central, South Central US, UK South, and West Europe. For an up-to-date list of regions and models, check here.
- 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: all
azd
commands assume that the user has run bothazd auth login
and theazd init -t {repo}
first
azd init
only needs to be run once when first setting up the environment
To run the code locally:
- Clone this repository to your local environment.
- If not already done so, provision the infrastructure in the Azure subscription using
azd up
- Change to the directory
.\app-code
- Run the script
.\start.ps1
To only provision the infrastructure
- Run the command
azd provision
To only deploy the code
- Run the command
azd deploy
To test packaging of any changes
- Run the command
azd package
To give someone else access to a completely deployed and existing environment, either you or they can follow these steps:
- Install the Azure CLI
- Run
azd init -t Patrick-Davis-MSFT/AOAI-Prompt-Demos
or clone this repository. - Run
azd env refresh -e {environment name}
They will need the azd environment name, subscription ID, and location to run this command. You can find those values in your.azure/{env name}/.env
file. This will populate their azd environment's.env
file with all the settings needed to run the app locally. - Set the environment variable
AZURE_PRINCIPAL_ID
either in that.env
file or in the active shell to their Azure ID, which they can get withaz account show
. - Run
./scripts/roles.ps1
or.scripts/roles.sh
to assign all of the necessary roles to the user. If they do not have the necessary permission to create roles in the subscription, then you may need to run this script for them. Once the script runs, they should be able to run the app locally.