name | description | languages | products | page_type | urlFragment | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Contoso Chat - RAG-based Retail copilot with Azure AI Studio |
Build, evaluate, and deploy, a RAG-based retail copilot using Azure AI with Promptflow. |
|
|
sample |
contoso-chat |
Contoso Chat is the signature Python sample demonstrating how to build, evaluate, and deploy, a retail copilot application end-to-end with Azure AI Studio using Promptflow (flex-flow) with Prompty assets.
In this sample we build, evaluate and deploy a support chat agent for Contoso Outdoors, a fictitious retailer who sells hiking and camping equipment. The implementation uses a Retrieval Augmented Generation approach to answer customer queries with responses grounded in the company's product catalog and customer purchase history.
The sample uses the following Azure technologies:
- Azure AI Search to create and manage search indexes for product catalog data
- Azure Cosmos DB to store and manage customer purchase history data
- Azure OpenAI to deploy and manage key models for our copilot workflow
text-embeddings-ada-002
for vectorizing user queriesgpt-4
for AI-assisted evaluationgpt-35-turbo
for generating chat responses
By exploring and deploying this sample, you will learn to:
- Build a retail copilot application using the RAG pattern.
- Define and engineer prompts using the Prompty asset.
- Design, run & evaluate a copilot using the Promptflow framework.
- Provision and deploy the solution to Azure using the Azure Developer CLI.
- Explore and understand Responsible AI practices for evaluation and content safety.
This is the signature sample for showcasing end-to-end development of a copilot application code-first on the Azure AI platform and has been actively used for training developer audiences and partners at signature events including Microsoft AI Tour and Microsoft Build. This section maintains links to prior versions associated with the relevant events and workshops for reference.
Version Description v0 : #cc2e808 Microsoft AI Tour 2023-24 (dag-flow, jnja template) - Skillable Lab v1 : msbuild-lab322 Microsoft Build 2024 (dag-flow, jnja template) - Skillable Lab v2 : main Latest version (flex-flow, prompty asset)- Azure AI Template
This sample builds the chat AI (copilot backend) that can be deployed to Azure AI Studio as a hosted API (endpoint) for integrations with front-end applications. For demonstration purposes only, the chat UI (retail front-end website) was prototyped in a second sample: contoso-web that provides the user experience shown below. Revisit this section for future updates on chat-UI samples that are Azure AI template ready for convenience.
The project comes with:
- Sample model configurations, chat and evaluation prompts for a RAG-based copilot app.
- Prompty assets to simplify prompt creation & iteration for this copilot scenario.
- Sample product and customer data for the retail copilot scenario.
- Sample application code for copilot chat and evaluation workflows.
- Sample azd-template configuration for managing the application on Azure.
- Managed Identity configuration as a best practice for managing sensitive credentials.
This is also a signature sample for demonstrating the end-to-end capabilities of the Azure AI platform. Expect regular updates to showcase cutting-edge features and best practices for generative AI development.
The Contoso Chat application implements a retrieval augmented generation pattern to ground the model responses in your data. The architecture diagram below illustrates the key components and services used for implementation and highlights the use of Azure Managed Identity to reduce developer complexity in managing sensitive credentials.
- Azure Subscription - Signup for a free account here.
- Visual Studio Code - Download it for free here.
- GitHub Account - Signup for a free account here.
- Access to Azure Open AI Services - Apply for access here.
You will also need to validate the following requirements:
- Access to semantic ranker feature for your search service tier and deployment region.
- Access to sufficient Azure OpenAI quota for your selected models and deployment region.
![!Note] In this template, we have pre-configured Azure AI Search for deployment in
eastus
, while all other resources get deployed to the defaultlocation
specified during the azd-driven deployment. This is primarily due to the limited regional availability of the semantic ranker feature at present. By using a default location for the search resource, we can now be more flexible in selecting the location for deploying other resources (e.g., to suit your model quota availability).
You have three options for getting started with this template:
- GitHub Codespaces - Cloud-hosted dev container (pre-built environment)
- VS Code Dev Containers - Locally-hosted dev container (pre-built environment)
- Manual Setup - Local environment setup (for advanced users)
We recommend the first option for the quickest start with minimal effort required. The last option requires the most user effort offers maximum control over your setup. All three options are documented below - pick one.
Once you complete setup, use these commands to validate the install:
-
Click the button to launch this repository in GitHub Codespaces.
-
This should launch a new browser tab for GitHub Codespaces setup. The process may take a few minutes to complete.
-
Once ready, the tab will refresh to show a Visual Studio Code editor in the browser.
-
Open the terminal in VS Code and validate install with these commands:
azd version
- Azure Developer CLI is installed (v1.8.2+)pf version
- Promptflow is installed (v1.10.0+)az version
- Azure CLI is installed (v2.60+)python3 --version
- Python3 is installed (v3.11+)
-
Sign into your Azure account from the VS Code terminal
azd auth login --use-device-code
-
Congratulations! You are ready to move to the Azure Deployment step.
A related option is VS Code Dev Containers, which will open the project in your local VS Code using the Dev Containers extension:
-
Start Docker Desktop (install it if not already installed)
-
Open the project by clickjing the button below:
-
Once ready, the tab will refresh to show a Visual Studio Code editor in the browser.
-
Open the terminal in VS Code and validate install with these commands:
azd version
- Azure Developer CLI is installed (v1.8.2+)pf version
- Promptflow is installed (v1.10.0+)az version
- Azure CLI is installed (v2.60+)python3 --version
- Python3 is installed (v3.11+)
-
Sign into your Azure account from the VS Code terminal
azd auth login
-
Congratulations! You are ready to move to the Azure Deployment step.
- Verify you have Python3 installed on your machine.
- Install dependencies with
pip install -r requirements.txt
- Install dependencies with
- Install Azure CLI
- Install Azure Developer CLI
- Windows:
winget install microsoft.azd
- Linux:
curl -fsSL https://aka.ms/install-azd.sh | bash
- MacOS:
brew tap azure/azd && brew install azd
- Windows:
- Validate install with these commands:
azd version
- Azure Developer CLI is installed (v1.8.2+)pf version
- Promptflow is installed (v1.10.0+)az version
- Azure CLI is installed (v2.60+)python3 --version
- Python3 is installed (v3.11+)
Complete these steps in the same terminal that you used previously, to authenticate with Azure.
- Provision Azure resources and deploy your application with one command. The process should ask you for an environment name (maps to resource group) and a location (Azure region) and subscription for deployment.
azd up
- Verify that your application was provisioned correctly.
- Visit the Azure Portal and verify the resource group (above) was created.
- Visit the Azure AI Studio site and verify the AI project was created.
- Congratulations! Your setup step is complete.
The core functionality of the copilot application is developed using the Promptflow framework with Python. In this project, we use the Promptflow extension in Visual Studio Code, with its pf
commandline tool, for all our local development needs.
🚨 TODO
More details can be found in the documentation section of this repo.
You can estimate the cost of this project's architecture with Azure's pricing calculator
- Azure OpenAI - Standard tier, GPT-4, GPT-35-turbo and Ada models. See Pricing
- Azure AI Search - Basic tier, Semantic Ranker enabled See Pricing
- Azure Cosmos DB for NoSQL - Serverless, Free Tier See Pricing
We recommend using keyless authentication for this project. Read more about why you should use managed identities on our blog.
- Azure AI Studio Documentation
- Promptflow Documentation
- Prompty Assets
- Flex Flow
- [Link to similar sample] 🚧
Have questions or issues to report? Please open a new issue after first verifying that the same question or issue has not already been reported. In the latter case, please add any additional comments you may have, to the existing issue.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.