Skip to content

Build a Copilot application with Azure OpenAI Service, Azure Cosmos DB & Azure App Service.

License

Notifications You must be signed in to change notification settings

markjbrown/cosmosdb-nosql-copilot

 
 

Repository files navigation

page_type languages products urlFragment name description
sample
azdeveloper
bicep
aspx-csharp
csharp
dockerfile
nosql
azure
azure-cosmos-db
azure-app-service
azure-openai
ai-samples
Build Copilot app using Azure Cosmos DB for NoSQL
Build a Copilot app using Azure Cosmos DB for NoSQL, Azure OpenAI Service, Azure App Service and Semantic Kernel

Build a Copilot app using Azure Cosmos DB for NoSQL, Azure OpenAI Service, Azure App Service and Semantic Kernel

This sample application shows how to build a multi-tenant, multi-user, Generative-AI RAG Pattern application using Azure Cosmos DB for NoSQL with its new vector database capabilities with Azure OpenAI Service on Azure App Service. This sample shows both using Native SDKs as well as Semantic Kernel integration. The sample provides practical guidance on many concepts you will need to design and build these types of applications.

Concepts Covered

This application demonstrates the following concepts and how to implement them:

  • How to build a highly scalable, multi-tenant & user, Generative-AI chat application using Azure Cosmos DB for NoSQL.
  • Generating completions and embeddings using Azure OpenAI Service.
  • Managing a context window (chat history) for natural conversational interactions with an LLM.
  • Manage per-request token consumption and payload sizes for Azure OpenAI Service requests.
  • Building a semantic cache using Azure Cosmos DB for NoSQL vector search for improved performance and cost.
  • Using the Semantic Kernel SDK for completion and embeddings generation.
  • Implementing RAG Pattern using vector search in Azure Cosmos DB for NoSQL on custom data to augment generated responses from an LLM.

Architecture Diagram

Architecture Diagram

User Experience

Cosmos DB + ChatGPT user interface

Getting Started

Prerequisites

  • Azure subscription. Start free

  • Subscription access to Azure OpenAI service. Start here to Request Access to Azure OpenAI Service. If you have access, see below for ensuring enough quota to deploy.

  • Enroll in the Azure Cosmos DB for NoSQL Vector Search Preview (See below for more details)

  • .NET 8 or above. Download

  • Azure Developer CLI

  • Visual Studio, VS Code, GitHub Codespaces or another editor to edit or view the source for this sample.

    Vector search Preview details

    This lab utilizes a preview feature, Vector search for Azure Cosmos DB for NoSQL which requires preview feature registration. Follow the below steps to register. You must be enrolled before you can deploy this solution:

    1. Navigate to your Azure Cosmos DB for NoSQL resource page.
    2. Select the "Features" pane under the "Settings" menu item.
    3. Select for “Vector Search in Azure Cosmos DB for NoSQL”.
    4. Read the description to confirm you want to enroll in the preview.
    5. Select "Enable" to enroll in the Vector Search preview.

    Checking Azure OpenAI quota limits

    For this sample to deploy successfully, there needs to be enough Azure OpenAI quota for the models used by this sample within your subscription. This sample deploys a new Azure OpenAI account with two models, gpt-4o with 10K tokens per minute and text-3-large with 5k tokens per minute. For more information on how to check your model quota and change it, see Manage Azure OpenAI Service Quota

Instructions

  1. Open a terminal and navigate to where you would like to clone this solution

  2. Run the following command to download:

    azd init -t AzureCosmosDB/cosmosdb-nosql-copilot
  3. From the terminal, navigate to the /infra directory in this solution.

  4. Log in to AZD.

    azd auth login
  5. Deploy the services to Azure, build your container, and deploy the application.

    azd up

Quickstart

This solution has a number of quickstarts than you can run through to learn about the features in this sample and how to implement them yourself.

Please see Quickstarts

Clean up

  1. Open a terminal and navigate to the /infra directory in this solution.

  2. Type azd down

    azd down

Resources

To learn more about the services and features demonstrated in this sample, see the following:

About

Build a Copilot application with Azure OpenAI Service, Azure Cosmos DB & Azure App Service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 44.2%
  • HTML 30.7%
  • Bicep 24.1%
  • Dockerfile 0.6%
  • JavaScript 0.2%
  • PowerShell 0.1%
  • Shell 0.1%