Skip to content

Sample application that combines Azure Cosmos DB with Azure OpenAI ChatGPT service

License

Notifications You must be signed in to change notification settings

ShahinKohan/cosmosdb-chatgpt

 
 

Repository files navigation

page_type languages products name urlFragment description azureDeploy
sample
csharp
azure-cosmos-db
azure-openai
Build a Copilot app using Azure Cosmos DB & Azure OpenAI Service
chat-app
Sample application that implements a Generative AI chat application that demonstrates context windows, semantic cache and Semantic Kernel integration.

Build a Copilot app using Azure Cosmos DB & Azure OpenAI Service

This sample application shows how to build a Generative-AI application using Azure Cosmos DB using its new vector search capabilities and Azure OpenAI Service and Semantic Kernel. The sample provides practical guidance on many concepts you will need to design and build these types of applications.

Cosmos DB + ChatGPT user interface

Concepts Covered

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

  • The basics of building a highly scalable 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 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.

Getting Started

Prerequisites

  • Azure Subscription
  • Subscription access to Azure OpenAI service. Start here to Request Access to Azure OpenAI Service
  • Visual Studio, VS Code, GitHub Codespaces or another editor to edit or view the source for this sample.
  • Azure Cosmos DB for NoSQL Vector Search Preview enrollment

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 preview.

Service Deployment

Click one of the Deploy to Azure buttons belows and follow the prompts in Azure Portal to deploy this solution. The first option deploys a new Azure OpenAI account. The second allows you to use an existing Azure OpenAI account.

The provided ARM Templates will provision the following resources:

  1. Azure Cosmos DB Serverless account with database and container with a vector embedding policy on the container and vector indexes defined.
  2. Azure OpenAI Service You must also specify a name for the deployment of the "completion" and "embedding" models used by this application.
  3. Azure App service Web application host for the ASP.NET Blazor application.

Note: You must have access to Azure Open AI service from your subscription before attempting to deploy this application.

All connection information for Azure Cosmos DB and Azure Open AI is zero-touch and injected as environment variables in the Azure App Service instance at deployment time.

Deploy to Azure

Deploy with existing Azure OpenAI account: Use a pre-existing Azure OpenAI service account with GPT 3.5 Turbo and ADA-002. Use this Deploy to Azure button below. Provide Azure OpenAI account name, key, and deployment names for GPT 3.5 Turbo and ADA-002 models.

Deploy with existing Azure OpenAI

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

To remove all the resources used by this sample, delete the resource group for your deployment.

Resources

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

About

Sample application that combines Azure Cosmos DB with Azure OpenAI ChatGPT service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 34.9%
  • Bicep 34.5%
  • HTML 29.7%
  • Other 0.9%