Skip to content

luminis-ams/azure-workshop-oai-qa

Repository files navigation

Luminis Azure Meetup Workshop - QA with Azure OpenAI Service

This workshop will show you how you can create such AI powered assistant that operates on your own business data without leaving your Azure account.

Contents

  • Documents (data/transformers_docs_full): We will use documentation of transformers library as example.
  • Infastructure Code (infra): Deploys the necessary resources to Azure.
  • Backend (workshop_oai_qa): Streamlit App that provides a simple UI to interact with the model.
  • Runbook (runbook.ipynb): Jupyter notebook that walks you through the process of creating the app.

Prerequisites

If you are following the live hands-on workshop, you will be provided with a free Azure subscription.

If you are following the workshop on your own, you will need to have an Azure subscription. You can create a free Azure subscription here.

Deploying Infrastructure

What will be deployed?

Before you start

Write down the following variables:

Login with the newly created account:

az login --tenant <tenantId>

Switch to your project subscription ID:

az account set --subscription <subscriptionId>

Find your Principal ID: This will be the user that indexes the documents. In this case, we assume it's run locally, thus we use the signed in user.

az ad signed-in-user show --output=json --query=objectId
# or
az ad signed-in-user show --output=json --query=id
# Depending on your cli version

Save your environment ID: To avoid collision with other participants, we will use the environment name as a suffix for the resource names. You can use your name or any other unique identifier. For example your initials and a random number: ed42

Deploying Infrastructure Resources

PROJECT=workshop-oai \
AZURE_SUBSCRIPTION_ID=<subscriptionId> \
AZURE_ENV_NAME=<environmentName> \
AZURE_LOCATION=eastus \
AZURE_PRINCIPAL_ID=<principalId> \
AZURE_AUTH_CLIENT_ID="" \
APP_WHITELIST_IP="<your ipv4 address>/32" \
bash scripts/deploy_infrastructure.sh

Write down the resourceGroup name.

Deploying the App Code

Deploy the app code to Azure App Service.

Write down the appBackendName

# Backend App Name:
az deployment group show -g <resourceGroup> -n web --query properties.outputs.name.value

Upload the code to Azure App Service:

az webapp up \
--runtime PYTHON:3.10 \
--sku B1 \
--name <appBackendName> \
--resource-group <resourceGroup> \
--subscription <subscriptionId>

Index the documents

Run the following command to create .env file.

bash scripts/create_env.sh <resourceGroup>

Install python dependencies:

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Index the documents:

python scripts/indexing.py

Test the app

Open the app url in the browser and ask a question about transformers library.