Welcome to Day 2๏ธโฃ of the Azure AI week on #60Days Of IA
Let's recap what we learned so far. In our kickoff post we set the stage by describing our application scenario (Contoso Chat), the paradigm shift for generative AI apps (LLM Ops) and the unified platform for streamlining development (Azure AI Studio). In the next post we walked through the signature Contoso Chat application sample to understand how we can implement that scenario using Azure AI Studio and Prompt flow - from building the chat function, to evaluating it, deploying it to a hosted endpoint, then testing that API in a chat client.
But what if you want to get started building your own application scenario? Over the next three posts, we'll look at starter samples that will get you from ideation (define chat function) to operationalization (deploy chat API) using different tools and frameworks to simplify orchestration.
Ready? Let's go!
What You'll Learn Todayโ
- What is the copilot architecture?
- What is the Azure AI SDK?
- What is the Quickstart sample?
- How can I customize and extend this for my scenario?
- Challenge: Fork this quickstart and build it, then extend it with your data.
- Resources: Bookmark this collection for training & documentation.
1 | Learning Objectivesโ
The copilot ai-sdk quickstart is a Python-based starter sample for a code-first approach to building a copilot experience on the Azure AI platform. Since this is the foundational sample, we'll use it to explore some of the details of the implementation and set the stage for you to explore customizing it further for your application requirements.
By the end of this tutorial you should be able to:
- Explain the functional components of the copilot architecture
- Explain the Azure resources required to implement a copilot
- Explain the core functionality provided by the Azure AI SDK
- Build, run, evaluate, and deploy, a basic copilot with Azure AI Studio.
- Explore the Azure AI curated VS Code environment to customize the sample
Keep in mind that this is a quickstart sample and is not meant for production use. We encourage you to extend and customize the sample to understand the platform capabilities and end-to-end development workflow. Make sure to validate the responses yourself and evaluate its suitability for your application needs in context.
2| Copilot Architectureโ
Let's first revisit the high-level application architecture for our copilot and familiarize ourselves with the core functional components. Our goal is to build the chat function component and deploy it to get a hosted Copilot API endpoint that we can integrate into front-end applications to provide a conversational chatbot capability grounded in our data.
Let's review what we will need to implement this architecture:
- Model Deployments - we need deployed models for chat and embeddings.
- Search Index - we need a search index populated with our product data.
- Azure Resources - we need to setup and configure our Azure AI project.
- App Evaluation - we need to evaluate copilot quality for responsible AI.
- App Deployment - we need to deploy the copilot for a hosted API endpoint.
The copilot ai-sdk quickstart provides a starter codebase that implements this chat function using the Retrieval Augmented Generation (RAG) pattern with custom data. The implementation makes use of Azure AI Studio and the Azure AI SDK (Python) for a code-first approach. Since these technologies are currently in preview, we expect the sample to keep evolving quickly and recommend following the README-based tutorial there for the latest instructions.
3 | Azure AI SDKโ
Before we dive into the sample, let's take a moment to learn about the Azure AI SDK for Python (preview). The SDK consists of two packages:
- azure-ai-generative - which provides the functionality needed for building, evaluating and deploying Generative AI applications. This has extra packages (index, evaluate, promptflow) you can use for enhanced local development capabilities - or optionally, remove if unused.
- azure-ai-resources - which provides the functionality for connecting to, and managing, your Azure AI projects and resources. Use this for control plane operations to create and manage data, indexes, models and deployments.
The generative package makes use of the resources package to create an AIClient
instance that can be used for connecting to the Azure AI project resources.
from azure.ai.resources.client import AIClient
from azure.identity import DefaultAzureCredential
ai_client = AIClient(
credential=DefaultAzureCredential(),
subscription_id='subscription_id',
resource_group_name='resource_group',
project_name='project_name'
)
Once connected, you can use the generative package to build an index, run a local evaluation, or deploy chat functions and prompt flows, using the imports shown:
from azure.ai.generative.index import build_index
from azure.ai.generative.evaluate import evaluate
from azure.ai.resources.entities.deployment import Deployment
To get started, you will need to install the SDK in your local development environment. When you use the quickstart sample with GitHub Codespaces or the Azure AI curated VS Code environment, the SDK comes pre-installed and ready to use.
4 | Using the Quickstart Sampleโ
The copilot ai-sdk quickstart provides a comprehensive README.md document that describes the step-by-step process for building, running, evaluating, and deploying, a starter copilot sample.
4.1 | Pre-Requisitesโ
To get started, you will need an active Azure subscription and have access to the Azure OpenAI service to create and deploy the required models for chat completion, chat evaluation and embedddings. You will also need a GitHub account.