GithubHelp home page GithubHelp logo

azure-samples / azure-search-openai-demo-csharp Goto Github PK

View Code? Open in Web Editor NEW
539.0 45.0 332.0 8.07 MB

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure Cognitive Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.

License: MIT License

Dockerfile 0.20% C# 52.34% HTML 14.81% CSS 1.55% PowerShell 1.40% Shell 2.36% Bicep 26.51% JavaScript 0.83% Smalltalk 0.01%
azd-templates chatgpt csharp openai dotnet azure

azure-search-openai-demo-csharp's Introduction

page_type languages products urlFragment name description
sample
azdeveloper
csharp
html
bicep
ai-services
azure-blob-storage
azure-container-apps
azure-cognitive-search
azure-openai
aspnet-core
blazor
defender-for-cloud
azure-monitor
dotnet-maui
azure-search-openai-demo-csharp
ChatGPT + Enterprise data (csharp)
A csharp sample app that chats with your data using OpenAI and AI Search.

Table of Contents

ChatGPT + Enterprise data with Azure OpenAI and Cognitive Search (.NET)

GitHub Workflow Status Open in GitHub - Codespaces Open in Remote - Containers

This sample demonstrates a few approaches for creating ChatGPT-like experiences over your own data using the Retrieval Augmented Generation pattern. It uses Azure OpenAI Service to access the ChatGPT model (gpt-35-turbo), and Azure AI Search for data indexing and retrieval.

The repo includes sample data so it's ready to try end-to-end. In this sample application, we use a fictitious company called Contoso Electronics, and the experience allows its employees to ask questions about the benefits, internal policies, as well as job descriptions and roles.

RAG Architecture

For more details on how this application was built, check out:

We want to hear from you! Are you interested in building or currently building intelligent apps? Take a few minutes to complete this survey.

Take the survey

Features

  • Voice Chat, Chat and Q&A interfaces
  • Explores various options to help users evaluate the trustworthiness of responses with citations, tracking of source content, etc.
  • Shows possible approaches for data preparation, prompt construction, and orchestration of interaction between model (ChatGPT) and retriever (Cognitive Search)
  • Settings directly in the UX to tweak the behavior and experiment with options

Chat screen

Application architecture

  • User interface - The application’s chat interface is a Blazor WebAssembly application. This interface is what accepts user queries, routes request to the application backend, and displays generated responses.
  • Backend - The application backend is an ASP.NET Core Minimal API. The backend hosts the Blazor static web application and what orchestrates the interactions among the different services. Services used in this application include:
    • Azure AI Search – indexes documents from the data stored in an Azure Storage Account. This makes the documents searchable using vector search capabilities.
    • Azure OpenAI Service – provides the Large Language Models to generate responses. Semantic Kernel is used in conjunction with the Azure OpenAI Service to orchestrate the more complex AI workflows.

Getting Started

Account Requirements

In order to deploy and run this example, you'll need

Warning

By default this sample will create an Azure Container App, and Azure AI Search resource that have a monthly cost, as well as Form Recognizer resource that has cost per document page. You can switch them to free versions of each of them if you want to avoid this cost by changing the parameters file under the infra folder (though there are some limits to consider; for example, you can have up to 1 free Cognitive Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document.)

Cost estimation

Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage. However, you can try the Azure pricing calculator for the resources below:

Project setup

You have a few options for setting up this project. The easiest way to get started is GitHub Codespaces, since it will setup all the tools for you, but you can also set it up locally if desired.

GitHub Codespaces

You can run this repo virtually by using GitHub Codespaces, which will open a web-based VS Code in your browser:

Open in GitHub - Codespaces

VS Code Remote Containers

A related option is VS Code Remote Containers, which will open the project in your local VS Code using the Dev Containers extension:

Open in Remote - Containers

Local environment

Install the following prerequisites:

  • Azure Developer CLI

  • .NET 8

  • Git

  • Powershell 7+ (pwsh) - For Windows users only.

    Important
    Ensure you can run pwsh.exe from a PowerShell command. If this fails, you likely need to upgrade PowerShell.

  • Docker

    Important
    Ensure Docker is running before running any azd provisioning / deployment commands.

Then, run the following commands to get the project on your local environment:

  1. Run azd auth login
  2. Clone the repository or run azd init -t azure-search-openai-demo-csharp
  3. Run azd env new azure-search-openai-demo-csharp

Deployment

Deploying from scratch

Important
Ensure Docker is running before running any azd provisioning / deployment commands.

Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.

  1. Run azd up - This will provision Azure resources and deploy this sample to those resources, including building the search index based on the files found in the ./data folder.

    • For the target location, the regions that currently support the model used in this sample are East US 2 , East US or South Central US. For an up-to-date list of regions and models, check here
    • If you have access to multiple Azure subscriptions, you will be prompted to select the subscription you want to use. If you only have access to one subscription, it will be selected automatically.

    Note
    This application uses the gpt-35-turbo model. When choosing which region to deploy to, make sure they're available in that region (i.e. EastUS). For more information, see the Azure OpenAI Service documentation.

  2. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.

It will look like the following:

'Output from running azd up'

Note

It may take a few minutes for the application to be fully deployed.

Use existing resources

If you have existing resources in Azure that you wish to use, you can configure azd to use those by setting the following azd environment variables:

  1. Run azd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}
  2. Run azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
  3. Run azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT {Name of existing ChatGPT deployment}. Only needed if your ChatGPT deployment is not the default 'chat'.
  4. Run azd env set AZURE_OPENAI_EMBEDDING_DEPLOYMENT {Name of existing embedding model deployment}. Only needed if your embedding model deployment is not the default embedding.
  5. Run azd up

Note

You can also use existing Search and Storage Accounts. See ./infra/main.parameters.json for list of environment variables to pass to azd env set to configure those existing resources.

Deploying or re-deploying a local clone of the repo

Important

Ensure Docker is running before running any azd provisioning / deployment commands.

  • Run azd up

Deploying your repo using App Spaces

Note

Make sure you have AZD supported bicep files in your repository and add an initial GitHub Actions Workflow file which can either be triggered manually (for initial deployment) or on code change (automatically re-deploying with the latest changes) To make your repository compatible with App Spaces, you need to make changes to your main bicep and main parameters file to allow AZD to deploy to an existing resource group with the appropriate tags.

  1. Add AZURE_RESOURCE_GROUP to main parameters file to read the value from environment variable set in GitHub Actions workflow file by App Spaces.
    "resourceGroupName": {
       "value": "${AZURE_RESOURCE_GROUP}"
     }
  2. Add AZURE_TAGS to main parameters file to read the value from environment variable set in GitHub Actions workflow file by App Spaces.
    "tags": {
       "value": "${AZURE_TAGS}"
     }
  3. Add support for resource group and tags in your main bicep file to read the value being set by App Spaces.
    param resourceGroupName string = ''
    param tags string = ''
  4. Combine the default tags set by Azd with those being set by App Spaces. Replace tags initialization in your main bicep file with the following -
    var baseTags = { 'azd-env-name': environmentName }
    var updatedTags = union(empty(tags) ? {} : base64ToJson(tags), baseTags)
    Make sure to use "updatedTags" when assigning "tags" to resource group created in your bicep file and update the other resources to use "baseTags" instead of "tags". For example -
    ```json
    resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
      name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}'
      location: location
      tags: updatedTags
    }

Running locally

Important

Ensure Docker is running before running any azd provisioning / deployment commands.

  1. Run azd auth login

  2. After the application deploys, set the environment variable AZURE_KEY_VAULT_ENDPOINT. You can find the value in the .azure/YOUR-ENVIRONMENT-NAME/.env file or the Azure portal.

  3. Run the following .NET CLI command to start the ASP.NET Core Minimal API server (client host):

    dotnet run --project ./app/backend/MinimalApi.csproj --urls=http://localhost:7181/
    

Navigate to http://localhost:7181, and test out the app.

Running locally with the .NET MAUI client

This sample includes a .NET MAUI client, packaging the experience as an app that can run on a Windows/macOS desktop or on Android and iOS devices. The MAUI client here is implemented using Blazor hybrid, letting it share most code with the website frontend.

  1. Open app/app-maui.sln to open the solution that includes the MAUI client

  2. Edit app/maui-blazor/MauiProgram.cs, updating client.BaseAddress with the URL for the backend.

    If it's running in Azure, use the URL for the service backend from the steps above. If running locally, use http://localhost:7181.

  3. Set MauiBlazor as the startup project and run the app

Sharing Environments

Run the following if you want to give someone else access to the deployed and existing environment.

  1. Install the Azure CLI
  2. Run azd init -t azure-search-openai-demo-csharp
  3. Run azd env refresh -e {environment name} - Note that they will need the azd environment name, subscription Id, and location to run this command - you can find those values in your ./azure/{env name}/.env file. This will populate their azd environment's .env file with all the settings needed to run the app locally.
  4. Run pwsh ./scripts/roles.ps1 - This will assign all of the necessary roles to the user so they can run the app locally. If they do not have the necessary permission to create roles in the subscription, then you may need to run this script for them. Just be sure to set the AZURE_PRINCIPAL_ID environment variable in the azd .env file or in the active shell to their Azure Id, which they can get with az account show.

Clean up resources

Run azd down

Using the app

  • In Azure: navigate to the Azure Container App deployed by azd. The URL is printed out when azd completes (as "Endpoint"), or you can find it in the Azure portal.
  • When running locally, navigate to http://localhost:7181 for the client app and http://localhost:7181/swagger for the Open API server page.

Once in the web app:

  • On the Voice Chat page, select the voice settings dialog and configure text-to-speech preferences.
    • You can either type messages to interact with Blazor Clippy, or select the Speak toggle button to use speech-to-text as your input.
  • Try different topics in Chat context. For chat, try follow up questions, clarifications, ask to simplify or elaborate on answer, etc.
  • Explore citations and sources
  • Click on the "settings" icon to try different options, tweak prompts, etc.

Enabling optional features

Enabling Application Insights

To enable Application Insights and the tracing of each request, along with the logging of errors, set the AZURE_USE_APPLICATION_INSIGHTS variable to true before running azd up

  1. Run azd env set AZURE_USE_APPLICATION_INSIGHTS true
  2. Run azd up

To see the performance data, go to the Application Insights resource in your resource group, click on the "Investigate -> Performance" blade and navigate to any HTTP request to see the timing data. To inspect the performance of chat requests, use the "Drill into Samples" button to see end-to-end traces of all the API calls made for any chat request:

Tracing screenshot

To see any exceptions and server errors, navigate to the "Investigate -> Failures" blade and use the filtering tools to locate a specific exception. You can see Python stack traces on the right-hand side.

Enabling authentication

By default, the deployed Azure container app will have no authentication or access restrictions enabled, meaning anyone with routable network access to the container app can chat with your indexed data. You can require authentication to your Azure Active Directory by following the Add container app authentication tutorial and set it up against the deployed container app.

To then limit access to a specific set of users or groups, you can follow the steps from Restrict your Azure AD app to a set of users by changing "Assignment Required?" option under the Enterprise Application, and then assigning users/groups access. Users not granted explicit access will receive the error message -AADSTS50105: Your administrator has configured the application <app_name> to block users unless they are specifically granted ('assigned') access to the application.-

Enable GPT-4V support

With GPT-4-vision-preview(GPT-4V), it's possible to support an enrichmented retrival augmented generation by providing both text and image as source content. To enable GPT-4V support, you need to enable USE_VISION and use GPT-4V model when provisioning.

Note

You would need to re-indexing supporting material and re-deploy the application after enabling GPT-4V support if you have already deployed the application before. This is because enabling GPT-4V support requires new fields to be added to the search index.

To enable GPT-4V support with Azure OpenAI Service, run the following commands:

azd env set USE_VISION true
azd env set USE_AOAI true
azd env set AZURE_OPENAI_CHATGPT_MODEL_NAME gpt-4
azd env set AZURE_OPENAI_RESOURCE_LOCATION westus # gpt-4-vision-preview is only available in a few regions. Please check the model availability for more details.
azd up

To enable GPT-4V support with OpenAI, run the following commands:

azd env set USE_VISION true
azd env set USE_AOAI false
azd env set OPENAI_CHATGPT_DEPLOYMENT gpt-4-vision-preview
azd up

To clean up previously deployed resources, run the following command:

azd down --purge
azd env set AZD_PREPDOCS_RAN false # This is to ensure that the documents are re-indexed with the new fields.

Productionizing

This sample is designed to be a starting point for your own production application, but you should do a thorough review of the security and performance before deploying to production. Here are some things to consider:

  • OpenAI Capacity: The default TPM (tokens per minute) is set to 30K. That is equivalent to approximately 30 conversations per minute (assuming 1K per user message/response). You can increase the capacity by changing the chatGptDeploymentCapacity and embeddingDeploymentCapacity parameters in infra/main.bicep to your account's maximum capacity. You can also view the Quotas tab in Azure OpenAI studio to understand how much capacity you have.
  • Azure Storage: The default storage account uses the Standard_LRS SKU. To improve your resiliency, we recommend using Standard_ZRS for production deployments, which you can specify using the sku property under the storage module in infra/main.bicep.
  • Azure AI Search: If you see errors about search service capacity being exceeded, you may find it helpful to increase the number of replicas by changing replicaCount in infra/core/search/search-services.bicep or manually scaling it from the Azure Portal.
  • Azure Container Apps: By default, this application deploys containers with 0.5 CPU Cores and 1GB of memory. The minimum replicas is 1 and maximum 10. For this app, you can set values such as containerCpuCoreCount, containerMaxReplicas , containerMemory, containerMinReplicas in the infra/core/host/container-app.bicep file to fit your needs. You can use auto-scaling rules or scheduled scaling rules, and scale up the maximum/minimum based on load.
  • Authentication: By default, the deployed app is publicly accessible. We recommend restricting access to authenticated users. See Enabling authentication above for how to enable authentication.
  • Networking: We recommend deploying inside a Virtual Network. If the app is only for internal enterprise use, use a private DNS zone. Also consider using Azure API Management (APIM) for firewalls and other forms of protection. For more details, read Azure OpenAI Landing Zone reference architecture.
  • Loadtesting: We recommend running a loadtest for your expected number of users.

Resources

Note

The PDF documents used in this demo contain information generated using a language model (Azure OpenAI Service). The information contained in these documents is only for demonstration purposes and does not reflect the opinions or beliefs of Microsoft. Microsoft makes no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information contained in this document. All rights reserved to Microsoft.

FAQ

Question: Why do we need to break up the PDFs into chunks when Azure AI Search supports searching large documents?

Answer: Chunking allows us to limit the amount of information we send to OpenAI due to token limits. By breaking up the content, it allows us to easily find potential chunks of text that we can inject into OpenAI. The method of chunking we use leverages a sliding window of text such that sentences that end one chunk will start the next. This allows us to reduce the chance of losing the context of the text.

azure-search-openai-demo-csharp's People

Contributors

aaronpowell avatar adrianwyatt avatar amul047 avatar bretjohnson avatar cawams avatar coolcsh avatar dependabot[bot] avatar dluc avatar eilon avatar ievangelist avatar jmatthiesen avatar jongio avatar karstenjmsft avatar ladynaggaga avatar littlelittlecloud avatar luisquintanilla avatar microsoft-github-operations[bot] avatar paulyuk avatar svenaelterman avatar takyyon avatar v-xuto avatar vhvb1989 avatar yenchiho avatar zecloud avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-search-openai-demo-csharp's Issues

citation return ungrouped && sometimes it return info1.txt (which is example in prompt)

Please provide us with the following information:

This issue is for a: (mark with an 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

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Is there a plan to port the Semantic Kernel sample program Copilot Chat here?

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)

copilot app - https://github.com/microsoft/semantic-kernel/tree/main/samples/apps/copilot-chat-app is react ui,Is there a plan to port the Semantic Kernel sample program Copilot Chat here?

Invalid Plan String for ReadDecomposeAsk and ReadRetrieveRead approach

This is an known issue in semantic kernel that the planning string returned from LLM might be invalid in some situation.

Tracking issue in semantic kernel: microsoft/semantic-kernel#486

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

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

PrepDoc should split pdf into single pages before uploading to blob

We can use PdfSharpCore to split multi-page pdfs into single pages

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

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Action required: migrate or opt-out of migration to GitHub inside Microsoft

Migrate non-Open Source or non-External Collaboration repositories to GitHub inside Microsoft

In order to protect and secure Microsoft, private or internal repositories in GitHub for Open Source which are not related to open source projects or require collaboration with 3rd parties (customer, partners, etc.) must be migrated to GitHub inside Microsoft a.k.a GitHub Enterprise Cloud with Enterprise Managed User (GHEC EMU).

Action

✍️ Please RSVP to opt-in or opt-out of the migration to GitHub inside Microsoft.

❗Only users with admin permission in the repository are allowed to respond. Failure to provide a response will result to your repository getting automatically archived.🔒

Instructions

Reply with a comment on this issue containing one of the following optin or optout command options below.

✅ Opt-in to migrate

@gimsvc optin --date <target_migration_date in mm-dd-yyyy format>

Example: @gimsvc optin --date 03-15-2023

OR

❌ Opt-out of migration

@gimsvc optout --reason <staging|collaboration|delete|other>

Example: @gimsvc optout --reason staging

Options:

  • staging : This repository will ship as Open Source or go public
  • collaboration : Used for external or 3rd party collaboration with customers, partners, suppliers, etc.
  • delete : This repository will be deleted because it is no longer needed.
  • other : Other reasons not specified

Need more help? 🖐️

Deploy fails at redis container app

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

azd up

Any log messages given by the failure

Deployment Error Details:
ContainerAppOperationError: Failed to provision revision for container app 'redis'. Error details: Operation expired.

Update main.bicep

  • Update OpenAI resource to use OpenAI location environment variable

      location: openAiResourceGroupLocation
    
  • Remove gpt deployment AZURE_OPENAI_GPT_DEPLOYMENT / gptDeploymentName

  • Update to 0613 version of the chat model

How to run project in Visual Studio

Hi, i want to start the Project from within Visual Studio 2022 to use its debugger.
The Issue is that i get Nullreferenz errors because i dont have the azure development cli env variables.
Do you have a documentation on how to set up Visual Studio to debug the Project.

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

- [X] feature request

Minimal steps to reproduce

starting the Project from within Visual Studio 2022

OS and Version?

Windows 10

Mention any other details that might be useful


Thanks! We'll be in touch soon.

TODO

Please provide us with the following information:

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)

Current TODO lists in my mind is

  • Convert MVC backend to minimal API
  • Configure codespace && devContainer && adding to README.md page
  • Adding the rest of retrieval-read methods in backends
    • /chat (wip - xiaoyuz)
    • /ask ReadRetrieveRead
    • /ask ReadDecomposeAsk

And feel free to make any CURD changes on that list

To-Do improvements

Please provide us with the following information:

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)

Updating/work-with this template for GHA feature.

Please provide us with the following information:

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)

We are updating this template to support new features in Github Action.

For the Github Action feature: We will remove two lines of code on container image and add GHA code after checkout step in the .github/workflow/azure-dev.yml file. (Shown as below)

image

@rajeshkamal5050 , @IEvangelist , @jongio for notification.

Documentation suggests you can use a cheap Azure Cognitive Search, but you can't

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

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

Minimal steps to reproduce

The documentation in the readme suggests you can use a cheap Azure Cognitive Search to test with:

Warning

By default this sample will create an Azure App Service, Azure Static Web App, and Azure Cognitive Search resource that have a monthly cost, as well as Form Recognizer resource that has cost per document page. You can switch them to free versions of each of them if you want to avoid this cost by changing the parameters file under the infra folder (though there are some limits to consider; for example, you can have up to 1 free Cognitive Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document.)

I have successfully switched the Form Recogniser to sku F0 to reduce cost. However trying to use the free cognitive search doesn't work:

BadRequest: Semantic Search requires the search service be on a Standard or Storage Optimized Tier. Please refer to https://aka.ms/semanticsearchavailability for more details.

This combined with #108 has meant I've burnt quite a bit of money just trying to get his app running successfully 👎 (it took me ages a couple of days to realise azd down doesn't clean up properly, and search standard is £200 per month in my region)

Any log messages given by the failure

BadRequest: Semantic Search requires the search service be on a Standard or Storage Optimized Tier. Please refer to https://aka.ms/semanticsearchavailability for more details.

Expected/desired behavior

Following the documentation works

OS and Version?

Windows 10

Sharepoint Online as your knowledge base

Please provide us with the following information:

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)

OS and Version?

macOS Ventura

Versions

If you would like Sharepoint online to be your knowledge base, how would you approach this challenge? Would you use a storage account and connect to Sharepoint Online using REST API https://learn.microsoft.com/en-us/azure/search/search-howto-index-sharepoint-online ?


Thanks! We'll be in touch soon.

Add testing projects

The app currently has zero tests. Let's change that.

  • Add xUnit tests for testable/applicable logic.
  • #29
  • Add E2E testing with Playwright.

Project unable to be deployed - PrepareDocs throws an exception.

I've changed my main.bicep to use the correct ChatGPT version, everything is smooth sailing, but the PrepareDocs project fails to execute properly, throwing the following error upon deploying the application:

Unhandled exception: Azure.Identity.AuthenticationFailedException: Azure PowerShell authentication failed due to an unknown error. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/powershellcredential/troubleshoot Process terminated. The type initializer for 'Microsoft.PowerShell.Telemetry.ApplicationInsightsTelemetry' threw an exception.
   at System.Environment.FailFast(System.String, System.Exception)
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
   at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
System.TypeInitializationException: The type initializer for 'Microsoft.PowerShell.Telemetry.ApplicationInsightsTelemetry' threw an exception.
 ---> System.ArgumentException: There was an error parsing the Connection String: Input contains invalid delimiters and cannot be parsed. Expected example: 'key1=value1;key2=value2;key3=value3'.
 ---> System.ArgumentException: Input contains invalid delimiters and cannot be parsed. Expected example: 'key1=value1;key2=value2;key3=value3'.
   at Microsoft.ApplicationInsights.Extensibility.Implementation.ConfigString.ConfigStringParser.Parse(String configString)
   at Microsoft.ApplicationInsights.Extensibility.Implementation.Endpoints.EndpointProvider.ParseConnectionString(String connectionString)
   --- End of inner exception stack trace ---
   at Microsoft.ApplicationInsights.Extensibility.Implementation.Endpoints.EndpointProvider.ParseConnectionString(String connectionString)
   at Microsoft.ApplicationInsights.Extensibility.Implementation.Endpoints.EndpointProvider.set_ConnectionString(String value)
   at Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.set_ConnectionString(String value)
   at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.SelectInstrumentationKey(TelemetryConfiguration configuration)
   at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.Initialize(TelemetryConfiguration configuration, TelemetryModules modules, String serializedConfiguration)
   at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.Initialize(TelemetryConfiguration configuration, TelemetryModules modules)
   at Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CreateDefault()
   at Microsoft.PowerShell.Telemetry.ApplicationInsightsTelemetry..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.PowerShell.Telemetry.ApplicationInsightsTelemetry.SendPSCoreStartupTelemetry(String mode)
   at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText)
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
   at Azure.Identity.AzurePowerShellCredential.RequestAzurePowerShellAccessTokenAsync(Boolean async, TokenRequestContext context, CancellationToken cancellationToken)
   at Azure.Identity.AzurePowerShellCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
   at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)
   at Azure.Identity.AzurePowerShellCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
   at Azure.Identity.AzurePowerShellCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
   at Azure.Identity.DefaultAzureCredential.GetTokenFromSourcesAsync(TokenCredential[] sources, TokenRequestContext requestContext, Boolean async, CancellationToken cancellationToken)
   at Azure.Identity.DefaultAzureCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
   at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage)
   at Azure.Identity.DefaultAzureCredential.GetTokenImplAsync(Boolean async, TokenRequestContext requestContext, CancellationToken cancellationToken)
   at Azure.Identity.DefaultAzureCredential.GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
   at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueFromCredentialAsync(TokenRequestContext context, Boolean async, CancellationToken cancellationToken)
   at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueAsync(HttpMessage message, TokenRequestContext context, Boolean async)
   at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueAsync(HttpMessage message, TokenRequestContext context, Boolean async)
   at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AuthenticateAndAuthorizeRequestAsync(HttpMessage message, TokenRequestContext context)
   at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
   at Azure.Search.Documents.IndexesRestClient.ListAsync(String select, CancellationToken cancellationToken)
   at Azure.Search.Documents.Indexes.SearchIndexClient.<>c__DisplayClass58_0.<<GetIndexNamesAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+MoveNext()
   at Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Program.<<Main>$>g__CreateSearchIndexAsync|16_3(AppOptions options) in C:\Users\kiril.karagyozov\Downloads\azure-search-openai-demo-csharp-main (2)\azure-search-openai-demo-csharp-main\app\prepdocs\PrepareDocs\Program.cs:line 167
   at Program.<<Main>$>g__CreateSearchIndexAsync|16_3(AppOptions options) in C:\Users\kiril.karagyozov\Downloads\azure-search-openai-demo-csharp-main (2)\azure-search-openai-demo-csharp-main\app\prepdocs\PrepareDocs\Program.cs:line 167
   at Program.<>c.<<<Main>$>b__16_0>d.MoveNext() in C:\Users\kiril.karagyozov\Downloads\azure-search-openai-demo-csharp-main (2)\azure-search-openai-demo-csharp-main\app\prepdocs\PrepareDocs\Program.cs:line 14
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()

Update document ingestion pipeline to .NET

Please provide us with the following information:

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)

Mention any other details that might be useful

Today the prepdocs.py is what orchestrates the document ingestion pipeline. Update the code to use .NET.

https://github.com/Azure-Samples/azure-search-openai-demo-csharp/blob/main/scripts/prepdocs.py


Thanks! We'll be in touch soon.

how to update pdf?

Please provide us with the following information:

This issue is for a: (mark with an 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

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Add ASP.NET Core Blazor frontend

The current app was a port of the following GitHub repo:

This app was written in Python for the backend and React for the frontend. Ideally, this app will demonstrate C# for the backend with ASP.NET Core Minimal APIs and ASP.NET Core Blazor for the frontend experience. We already have an existing app that we're using as the inspiration for the UX:

Enabling semantic ranking results in HTTP 500 errors

2023-06-22T07:25:06.592683253Z fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
2023-06-22T07:25:06.592781202Z       An unhandled exception has occurred while executing the request.
2023-06-22T07:25:06.592813970Z       Azure.RequestFailedException: Highlighting is not supported for 'captions' parameter with 'none'.
2023-06-22T07:25:06.592858873Z       Parameter name: captions
2023-06-22T07:25:06.592863075Z       Status: 400 (Bad Request)
2023-06-22T07:25:06.592867453Z       ErrorCode: InvalidRequestParameter
2023-06-22T07:25:06.592871636Z       
2023-06-22T07:25:06.592875694Z       Content:
2023-06-22T07:25:06.592885155Z       {"error":{"code":"InvalidRequestParameter","message":"Highlighting is not supported for 'captions' parameter with 'none'.\r\nParameter name: captions","details":[{"code":"InvalidCaptionsOption","message":"Highlighting is not supported for 'captions' parameter with 'none'."}]}}
2023-06-22T07:25:06.592889568Z       
2023-06-22T07:25:06.592893559Z       Headers:
2023-06-22T07:25:06.593161545Z       Cache-Control: no-cache,no-store
2023-06-22T07:25:06.593171816Z       Pragma: no-cache
2023-06-22T07:25:06.593176598Z       Server: Microsoft-IIS/10.0
2023-06-22T07:25:06.593181519Z       client-request-id: 0ce20213-3a9e-4b1d-b956-63ebf179a5f8
2023-06-22T07:25:06.593186431Z       x-ms-client-request-id: 0ce20213-3a9e-4b1d-b956-63ebf179a5f8
2023-06-22T07:25:06.593190703Z       request-id: 0ce20213-3a9e-4b1d-b956-63ebf179a5f8
2023-06-22T07:25:06.593209231Z       elapsed-time: 54
2023-06-22T07:25:06.593213742Z       Strict-Transport-Security: REDACTED
2023-06-22T07:25:06.593220076Z       Date: Thu, 22 Jun 2023 07:25:06 GMT
2023-06-22T07:25:06.593224860Z       Content-Length: 277
2023-06-22T07:25:06.593227767Z       Content-Type: application/json; charset=utf-8
2023-06-22T07:25:06.593230589Z       Content-Language: REDACTED
2023-06-22T07:25:06.593233357Z       Expires: -1
2023-06-22T07:25:06.593236139Z       
2023-06-22T07:25:06.593240949Z          at Azure.Search.Documents.SearchClient.SearchInternal[T](SearchOptions options, String operationName, Boolean async, CancellationToken cancellationToken)
2023-06-22T07:25:06.593244524Z          at Azure.Search.Documents.SearchClient.SearchInternal[T](String searchText, SearchOptions options, Boolean async, CancellationToken cancellationToken)
2023-06-22T07:25:06.593247611Z          at Azure.Search.Documents.SearchClient.SearchAsync[T](String searchText, SearchOptions options, CancellationToken cancellationToken)
2023-06-22T07:25:06.593257855Z          at MinimalApi.Extensions.SearchClientExtensions.QueryDocumentsAsync(SearchClient searchClient, String query, RequestOverrides overrides, CancellationToken cancellationToken) in /src/backend/Extensions/SearchClientExtensions.cs:line 37
2023-06-22T07:25:06.593261229Z          at MinimalApi.Services.ReadRetrieveReadChatService.ReplyAsync(ChatTurn[] history, RequestOverrides overrides, CancellationToken cancellationToken) in /src/backend/Services/ReadRetrieveReadChatService.cs:line 91
2023-06-22T07:25:06.593264739Z          at MinimalApi.Extensions.WebApplicationExtensions.OnPostChatAsync(ChatRequest request, ReadRetrieveReadChatService chatService, CancellationToken cancellationToken) in /src/backend/Extensions/WebApplicationExtensions.cs:line 72
2023-06-22T07:25:06.593267766Z          at Microsoft.AspNetCore.Http.RequestDelegateFactory.ExecuteTaskResult[T](Task`1 task, HttpContext httpContext)
2023-06-22T07:25:06.593271490Z          at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass90_2.<<HandleRequestBodyAndCompileRequestDelegateForJson>b__2>d.MoveNext()
2023-06-22T07:25:06.593275371Z       --- End of stack trace from previous location ---
2023-06-22T07:25:06.593279535Z          at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
2023-06-22T07:25:06.593283903Z          at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

Those are my logs.

DeploymentFailed: BadRequest: NetworkAcls is required for this resource

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

azd up

Any log messages given by the failure

ERROR: deployment failed: error deploying infrastructure: failed deploying: deploying to subscription:

Deployment Error Details:
BadRequest: NetworkAcls is required for this resouce.

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

macOS Ventura

Versions

Mention any other details that might be useful

I was able to resolve this issue with the fix mentioned in this bug report: Azure-Samples/azure-search-openai-demo#133


Thanks! We'll be in touch soon.

failed building service 'web'

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. Open repo in Codespaces
  2. open bash terminal
  3. execute azd auth login
  4. execute azd up

Any log messages given by the failure

image

Expected/desired behavior

Deploy the solution into specified azure subscription

OS and Version?

Opened the repo with provided Codespaces

Mention any other details that might be useful

Deployment failed because of "redis"

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

I tried to deploy the demo to a fresh azure setup with the following commands

  • azd auth login
  • azd init -t azure-search-openai-demo-csharp
  • azd up

and everything works without any issue except the "redis"-resource. It fails with the following message

I also tried the python version (https://github.com/Azure-Samples/azure-search-openai-demo), and this works without any issues.
Do I need any specific permissions for the redis cache?

Any log messages given by the failure

{
"code": "ContainerAppOperationError",
"message": "Failed to provision revision for container app 'redis'. Error details: Operation expired."
}

nothing else..

Expected/desired behavior

it should deploy without any issues.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
Win 11

Versions

latest version

Mention any other details that might be useful

deployment progress
image


Thanks! We'll be in touch soon.

azd init hangs for me

This issue is for a:

- [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)

I'm on a Mac and when I got to the "azd init ..." step I see this:
image
and it keeps doing that over and over. I stopped it after more than 30 minutes. Not sure how to recover.

I did however just skip the step and did azd up instead and that seems to have more luck. If the "azd init" isn't needed perhaps we should remove it. If it is needed I can help debug my looping issue if someone tells me what to look for or what to try.

failed deploying service 'web'

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

Deploy the application from scratch using azd up command.

The message pops up after the documents have been uploaded to Azure Blob Storage and indexed in Azure Search

Any log messages given by the failure

image

Deploying services (azd deploy)

(x) Failed: Deploying service web

ERROR: failed deploying service 'web': failing invoking action 'deploy', planning provisioning: planning infrastructure provisioning: creating parameters file: reading parameter file template: open C:\Dev\azure-search-openai-demo-csharp\infra\web.parameters.json: The system cannot find the file specified.

Expected/desired behavior

App and resources deploy successfully

OS and Version?

Windows 11

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Delayed answers and blank boxes

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

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

image

The answers appear to be delayed and every other answer showing up blank.

Docker is required

This issue is for a:

- [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)

The README doesn't mention that Docker is required due to the build that's done. It would be good to mention that.

Add support for local embeddings

Today, you have the option of using OpenAI to generate embeddings. However, it'd be good to also provide the option of using local models to generate embeddings.

  • Indentify embedding model to use
  • Convert model to ONNX
  • Use ML.NET for inferencing and generating embeddings.

Ask Question - Text Overflows when browser zoom >100%

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

Launch the app https://jolly-ocean-0d398a10f.3.azurestaticapps.net/ask
Set zoom to 115%

Any log messages given by the failure

N/A

Expected/desired behavior

Text adjusts to zoom / screen size settings

OS and Version?

Microsoft Edge on Windows

Versions

N/A

Mention any other details that might be useful

image


Thanks! We'll be in touch soon.

Duplicate followup questions

Please provide us with the following information:

This issue is for a: (mark with an 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

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

text-davinci-003 is not supported anymore for new deployements

Deployment Error Details:
InvalidTemplateDeployment: The template deployment 'openai' is not valid according to the validation procedure.
DeploymentModelNotSupported: Creating account deployment is not supported by the model 'text-davinci-003'. This is usually because there are better models available for the similar functionality.

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.