Giter Club home page Giter Club logo

cosmosdb-chatgpt's Introduction

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
  • Azure Developer CLI
  • 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.

Instructions

  1. Log in to AZD.

    azd auth login

    [!NOTE]
    This is only required once per install.

  2. Initialize the project in the current directory.

    azd init --template cosmosdb-chatgpt
  3. 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

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:

cosmosdb-chatgpt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cosmosdb-chatgpt's Issues

Assistance with adding data separation (in a multi-user env, users cannot see each others chats)

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ x ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  1. Start the application & have 2 users open it in a browser.
  2. User 1 can then see User 2's chats and vice versa.

Expected/desired behavior

User 1 should not be able to see User 2's chats & vice versa.

Mention any other details that might be useful

I've deployed this for a large company (enterprise) as a quick method of demoing Azure OpenAI across business and allowing users to get hands on with it. However, almost immediately, complaints started to come in and haven't stopped (regarding seeing each others conversations).

I'm not familiar with Blazor, but to counter this issue, I've added "easy-auth" and code to retrieve the users AAD Id, which is then stored in the session (and against messages) item in cosmos DB & is retrieved when the page loads via "NavMenu.razor", then gets passed to "ChatPane.razor" & "ChatService.cs" etc... as needed.

When sessions or ChatMessages are loaded, the UserId has also been added into the queries to CosmosDb, to ensure that only the users session data is returned.

However, seemingly randomly, the users view switches to see another persons chats (instead of their own).

I can repro this now, by starting a debug session in VS, then opening two browser sessions (logged in as different AAD users).
Post initial page load, both users see their own views, but randomly, Tab1 will have the same conversation displayed as Tab 2, refreshing the page (Tab1), then shows the correct data for Tab1 again (Tab2, remains unchanged).

Rince and repeat...

Code Example: Enterprise-Dev

Can anyone give me a nudge in the right direction please?

Chat sessions not being renamed

This issue is for a: (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Mention any other details that might be useful

There appears to be an issue where the Blazor front end is either not triggering the chat session rename or the Invoke method is not being called to refresh the UX when the ChatCompletion function returns the completion back to the front-end. I've tried running this locally and if I step through the code it works but if I let it run as-is this behavior appears. I've also tried this when fully deployed into App Service and get a similar result.

My guess is the refresh event is not being fired in Blazor Server but am not exactly sure.

@seesharprun or @sandeepsnairms is this something you can take a look at?

How to deploy this app w/ pre-existing Azure resources.

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x ] feature request

Minimal steps to reproduce

We already have an existing Azure OpenAI account, and a CosmosDB account. We'd like to be able to spin up this app, and point it to the afore mentioned existing services.

Any log messages given by the failure

N/A

Expected/desired behavior

Clone the web app only, and use environment variables or secrets in a pipeline to spin up the app using pre-existing Azure resources.

OS and Version?

GitHub Actions or Bitbucket Pipelines, using an Ubuntu based Docker container.

Versions

N/A

Mention any other details that might be useful


Thanks! We'll be in touch soon.

InvalidTemplateDeployment

when I use JSON template deploy got the error as follow:
{
"code": "InvalidTemplateDeployment",
"details": [
{
"code": "InsufficientQuota",
"message": "Insufficient quota. Cannot create/update/move resource 'apollo-openai'."
}
],
"message": "The template deployment 'Microsoft.Template-20230325180124' is not valid according to the validation procedure. The tracking id is '119d011c-9c19-45a3-af13-a4aa0d173921'. See inner errors for details."
}

Regression issue: Hide prompt

If you do not have a chat currently selected, the input prompt still shows up. This should be hidden in most cases.

No effect of the redeployment after the first deployment

I apologise for asking a silly question. I recently made some modifications to the frontend application. During the first deployment, the changes were successfully reflected in the application. However, subsequent deployments have not resulted in any visible changes to the application.

The below is the code to deploy/redeploy:
az deployment group create --resource-group <resource-group-name> --template-file azuredeploy.bicep --mode Complete

How I know the changes were not applied:

  • First deployment: Changed the title to v0.1 (Reflected)
  • Second deployment: Changed the title to v0.2 (Not reflected)

Many thanks!

OpenAI API response discrepancies between Azure OpenAI Playground and chat/completions

Please provide us with the following information:

This issue is for a: (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  1. I've uploaded a collection of documents to blob storage and indexed them using Azure Search service.
  2. I've begun querying these documents with various questions using Azure OpenAI playground, and I'm receiving accurate responses.
  3. However, when I utilize the Azure.AI.OpenAI client to pose the same questions, the responses are not as expected. Some questions yield no information at all, whereas they provide appropriate responses in the OpenAI playground.

Any log messages given by the failure

Here are my Chat Completion Options, which are same as configured in OpenAI playground:


ChatCompletionsOptions options = new()
{
    DeploymentName = _modelName,
    Messages =
    {
        systemMessage,
        userMessage
    },
    User = sessionId,
    AzureExtensionsOptions = new AzureChatExtensionsOptions()
    {
        Extensions = {
            new AzureSearchChatExtensionConfiguration() {
                SearchEndpoint = new Uri(_searchIndexEndpoint),
                IndexName = _searchIndexName,
                Authentication = new OnYourDataApiKeyAuthenticationOptions(_searchIndexApiAccessKey),
                Strictness = 3,
                DocumentCount = 5,
                ShouldRestrictResultScope = true
            }
        }
    },
    MaxTokens = 800,
    Temperature = 0.2f,
    NucleusSamplingFactor = 1f,
    FrequencyPenalty = 0,
    PresencePenalty = 0
}

Expected/desired behavior

OS and Version?

Windows 10 Enterprise

Versions

22H2

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.