一个在 Azure 中运行的基于检索增强生成模式的示例应用程序,使用 Azure 认知搜索进行检索,以及 Azure 和 OpenAI 大型语言模型。
一个在 Azure 中运行的基于检索增强生成模式的示例应用程序,使用 Azure 认知搜索进行检索,以及 Azure 和 OpenAI 大型语言模型。
page_type: sample languages:
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-4o-mini), 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.
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.
In order to deploy and run this example, you'll need
Microsoft.Authorization/roleAssignments/write permissions, such as User Access Administrator or Owner.[!WARNING]
By default this sample will create an Azure Container App, and Azure AI Search resource that have a monthly cost, as well as Azure AI Document Intelligence 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 Azure AI Search resource per subscription, and the free Azure AI Document Intelligence resource only analyzes the first 2 pages of each document.)
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:
To reduce costs, you can switch to free SKUs for various services, but those SKUs have limitations. See this guide on deploying with minimal costs for more details.
⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use, either by deleting the resource group in the Portal or running azd down.
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.
You can run this repo virtually by using GitHub Codespaces, which will open a web-based VS Code in your browser:
A related option is VS Code Remote Containers, which will open the project in your local VS Code using the Dev Containers extension:
Install the following prerequisites:
Powershell 7+ (pwsh) - For Windows users only.
Important: Ensure you can run
pwsh.exefrom a PowerShell command. If this fails, you likely need to upgrade PowerShell.
Important: Ensure Docker is running before running any
azdprovisioning / deployment commands.
Then, run the following commands to get the project on your local environment:
azd auth loginazd init -t azure-search-openai-demo-csharpazd env new azure-search-openai-demo-csharpLive stream: Deploying from scratch in CodeSpaces Live stream: Deploying from scratch in Windows 11
Important: Ensure Docker is running before running any
azdprovisioning / deployment commands.
Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.
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.
Note: This application uses the
gpt-4o-minimodel. 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.
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:
[!NOTE]: It may take a few minutes for the application to be fully deployed. After the application is deployed, it will also take a few minutes to process the documents to be added into the vector database.
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:
azd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT {Name of existing ChatGPT deployment}. Only needed if your ChatGPT deployment is not the default 'chat'.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.azd up[!NOTE]
You can also use existing Search and Storage Accounts. See
./infra/main.parameters.jsonfor list of environment variables to pass toazd env setto configure those existing resources.
[!IMPORTANT]
Ensure Docker is running before running any
azdprovisioning / deployment commands.
azd up[!NOTE]
Make sure you have AZD supported bicep fi
暂无开放 Issues,或尚未同步最近议题。