Skip to content

Want to build a production LLM Application with a Retrieval Augmented Generation architecture - but not sure where to start? Let's deconstruct contoso-chat to learn how we can do this with Azure AI Studio and Prompt Flow

License

Notifications You must be signed in to change notification settings

30DaysOf/deconstructing-contoso-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deconstructing Contoso Chat

Note

This is the developer guide associated with the Contoso Chat sample. The sample is actively evolving and the developer guide may not reflect the latest changes. Please refer to the Contoso Chat README for the most up-to-date information.

Contoso Chat Application


Contoso Outdoors: Chat UI

Contoso Outdoors is a fictitious retailer that sells a variety of camping and hiking gear to outdoor adventurers. The company has a website (contoso-web) that displays the catalog of available products, allowing customers to click on any product to learn more details about what it supports.

Contoso Chat Application

Contoso Chat: Retail Copilot

Contoso Chat (contoso-chat) is the AI-powered chatbot that adds an AI-driven customer support feature to the website. It is implemented as a retail copilot that uses retrieval augmented generation to ground customer responses in the company's product catalog and customer data. Visitors to the site can now ask questions about available products, and even get recommendations based on their previous purchases.

Contoso Chat Application

The Copilot Architecture

The copilot implementation uses a Retrieval Augmented Generation architecture that grounds the chat AI responses in your data. The high level architecture is shown below:

Contoso Chat Application

The main components are:

  • App - this is the chat UI frontend. It can be an application (like the Contoso Outdoors website) or any client capable of making HTTP requests to the REST API.
  • API - this is the copilot API endpoint. It provides a REST API for the chat AI backend, to support user interactions (request-response).
  • AI - this is the chat AI backend. It consists of the chat function (code-first) that orchestrates multiple steps of the workflow required to process the user request.

Here, the function implements a retrieval augemented generation pattern with three steps:

  • Retrieval - the incoming user query (natural language) is first converted to a vector (numeric representation) using an Embedding model. The vector is now used to query the Search Index for our product catalog to efficiently retrieve relevant product terms.
  • Augmentation - The returned results are used to augment the request (user prompt) to generate an enhanced query (model prompt).
  • Generation - The model prompt is now sent to the Chat Completion model to generate the final text response which we then return to the user.

Orchestrating all these steps is a non-trivial process. This is where the right tools and platforms can help. In this implementation, we take advantage of three core technologies:

  • Promptflow - an open-source framework and tooling that streamlines the orchestration of the various tools and functions required to build the AI.
  • Promptflow Extension - a Visual Studio Code extension that streamlines promptflow usage in your local development environment for the build-run-eval-deploy cycle.
  • Azure AI Studio - a unified platform for generative AI application development on Azure, with code-first (SDK/CLI) and low-code (UI) interfaces for developers.

Contoso Chat Workshop

This repository contains the developer guide that can be used for a self-guided or instructor-led workshop to walk through the Contoso Chat application sample.

Learning Objectives:

By the end of the workshop you should be able to:

  • Describe what a copilot and how it is architected.
  • Describe what retrieval augmented generation is and why it is useful.
  • Describe what LLMOps is and how it relates to end-to-end development
  • Describe Azure AI Studio and how it supports E2E development of generative AI apps.
  • Define, build and test a copilot application locally.
  • Evaluate the copilot for response quality and performance locally and in the cloud.
  • Deploy the copilot to the cloud and test it with built-in or remote app integrations.

Developer Workflow:

The illustrated guide provides a high-level overview of the key steps:

  1. Provision Azure - create the necessary Azure resources for our copilot - including core Azure AI resources along with supporting search and data services.
  2. Populate Data - add your company data to relevant services (e.g., product index in Azure AI Search, customer data in Azure Cosmos DB)
  3. Deploy Models - we use 3 models: Text Embedding (for RAG), Chat Completion (for response generation), and Chat Evaluation (for assessing quality).
  4. Add Connections - connect your chat flow to required resources (models, search, database) for processing the user request.
  5. Build Promptflow - define the chat AI workflow as a directed acyclic graph of nodes, each defining a tool (function) to process user requests and chain responses.
  6. Evaluate Application - create test data and use AI-assisted evaluation flows to assess quality of application requirements with multiple evaluation metrics.
  7. Deploy Application - upload the flow and related assets to Azure, and deploy the copilot application as a hosted API endpoint for app integrations.

Contoso Chat Application

Getting Started

Want to get started with the workshop?

  • Visit the hosted developer guide at Contoso Chat Workshop
  • Preview the developer guide locally with npm run dev

Questions or Issues?

Post an issue to this repo with your feedback. We welcome comments and contributions to help make this guide better.

About

Want to build a production LLM Application with a Retrieval Augmented Generation architecture - but not sure where to start? Let's deconstruct contoso-chat to learn how we can do this with Azure AI Studio and Prompt Flow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •