Lab 09-Building a Chat App(Using Python) Using a Azure OpenAI Service and RAG
Lab 09-Building a Chat App(Using Python) Using a Azure OpenAI Service and RAG
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.
Objective
Task 1: Install Azure Cli and set the policy scope to Local machine
1. In your windows search bar, type PowerShell. In the PowerShell dialog box, navigate and
click on Run as administrator. If you see the dialog box - Do you want to allow this app to
make changes to your device? then click on the Yes button.
2. Run the following command to install Azure Cli on the PowerShell
PowerShell copy
Set-ExecutionPolicy Unrestricted
3. Node-V file will be downloaded. Click on the downloaded file to set up Node.js
4. In the Welcome to the Node.js Setup Wizard window, click on the Next button.
5. In the End-User License Agreement window, select I accept the terms in the License
agreement radio button and click on the Next button.
9. In Completing the Node.js Setup Wizard window, click on the Finish button to complete the
installation process.
Task 3: Assign a user as an owner of an Azure subscription
1. Open your browser, navigate to the address bar, and type or paste the following URL:
https://portal.azure.com/, then press the Enter button.
2. In the Microsoft Azure window, use the User Credentials to login to Azure.
3. Then, enter the password and click on the Sign in button.
8. On the Access control(IAM) page, Click +Add and select Add role assignments.
9. In the Role tab, select the Privileged administrator roles and select Owner . Click Next
10. In the Add role assignment tab, select Assign access to User group or service principal.
Under Members, click +Select members
11. On the Select members tab , select your Azure OpenAI credentials and click Select.
12. In the Add role assignment page, Click Review + Assign, you will get a notification once the
role assignment is complete.
13. You will see a notification – added as Owner for Azure Pass-Sponsorship.
2. Open Visual Studio Code? dialog box appears, then click on the Open Visual Studio Code
button.
3. To Staring Dev container will take 13-15 min
4. Sign in to Azure with the Azure Developer CLI. Run the following command on the Terminal
BashCopy
azd auth login
5. Default browser opens to sign in .Sign in with your Azure subscription account.
6. Close the browser
7. Once logged in, the details of the Azure login are populated in the terminal.
BashCopy
azd up
2. prompted to enter an environment name, enter the chatsampleRAG
3. When prompted, select a subscription to create the resources and select a location East
US2, This location is used for most the resources including hosting.
6. save the value in the environment for future use (y/N) enter Y.
7. Wait until app is deployed. It may take 35-40 minutes for the deployment to
complete.
8. After the application has been successfully deployed, you see a URL displayed in the
terminal. Copy the URL.
9. Open your browser, navigate to the address bar, paste the link. Now, resource group will
open in a new browser
Task 8: Use chat app to get answers from PDF files
2. In the GPT+Eneterprise data |Sample web app page, enter the following text and click on
the Submit icon as shown in the below image.
What happens in a performence review?
Override prompt This is the prompt that is used to generate the answer.
template
Retrieve this many This is the number of search results that are used to generate the answer.
search results You can see these sources returned in the Thought
process and Supporting content tabs of the citation.
Exclude category This is the category of documents that are excluded from the search
results.
Use semantic ranker This is a feature of Azure AI Search that uses machine learning to
for retrieval improve the relevance of search results.
Use query- When both Use semantic ranker and Use query-contextual summaries are
contextual checked, the LLM uses captions extracted from key passages, instead of
summaries instead all the passages, in the highest ranked documents.
of whole
documents
Suggest follow-up Have the chat app suggest follow-up questions based on the answer.
questions
Retrieval mode Vectors + Text means that the search results are based on the text of
the documents and the embeddings of the documents. Vectors means
that the search results are based on the embeddings of the
documents. Text means that the search results are based on the text of
the documents.
Stream chat Stream response instead of waiting until the complete answer is available
completion for a respon
responses
8. Check the Suggest follow-up questions checkbox and ask the same question again.
9. Enter the following text and click on the Submit icon as shown in the below image.
What happens in a performance review?
10. The chat returned suggested follow-up questions such as the following
11. In the Settings tab, deselect Use semantic ranker for retrieval.
12. Enter the following text and click on the Submit icon as shown in the below image.
What happens in a performance review?
Task 9: Delete the Resources
1. To delete Resource group , type Resource groups in the Azure portal search bar, navigate
and click on Resource groups under Services.