This demo is based on azure-search-openai-demo and using static web app for frontend and Azure functions for the backend API's.
In addition to azure-search-openai-demo feature this repo includes:
- Ability to upload file from UI
- Update to newer version of langchain(0.0.141)
- Updated rrr ( read-retrieve-read) approach to use pandas dataframe and Bing search lookup in addition to Azure cognitive search
Note: update azure function config with
BING_SUBSCRIPTION_KEY
to use. Bing API service deployment is not yet included in theazd
infra deployment
- Create Azure functions in different programming language e.g. (C#) and easily replace using config file
- Static web page by default configured with AAD auth
IMPORTANT: In order to deploy and run this example, you'll need an Azure subscription with access enabled for the Azure OpenAI service. You can request access here. You can also visit here to get some free Azure credits to get you started.
AZURE RESOURCE COSTS by default this sample will create Azure App Service and Azure Cognitive Search resources 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.)
- Azure Developer CLI
- Python 3+
- Important: Python and the pip package manager must be in the path in Windows for the setup scripts to work.
- Important: Ensure you can run
python --version
from console. On Ubuntu, you might need to runsudo apt install python-is-python3
to linkpython
topython3
.
- Node.js
- 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.
- Important: Ensure you can run
- Static Web Apps Cli
- Azure Cli
- Azure functions Core Tools
NOTE: Your Azure Account must have
Microsoft.Authorization/roleAssignments/write
permissions, such as User Access Administrator or Owner.
- Create a new folder and switch to it in the terminal
- Run
azd login
- Run
az account set --subscription "<your target subscription>"
- Run
azd init
- For the target location, the regions that currently support the models used in this sample are East US or South Central US. For an up-to-date list of regions and models, check here. Make sure that all the intended services for this deployment have availability in your targeted regions.
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 - 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.
NOTE: It may take a minute for the application to be fully deployed.
- Run
azd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}
- Run
azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
- Run
azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT {Name of existing ChatGPT deployment}
. Only needed if your ChatGPT deployment is not the default 'chat'. - Run
azd env set AZURE_OPENAI_GPT_DEPLOYMENT {Name of existing GPT deployment}
. Only needed if your ChatGPT deployment is not the default 'davinci'. - 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 toazd env set
to configure those existing resources.
- Simply run
azd up
- In Azure: navigate to the Azure WebApp deployed by azd. The URL is printed out when azd completes (as "Endpoint"), or you can find it in the Azure portal.
- Running locally: navigate to 127.0.0.1:5000
Once in the web app:
- Try different topics in chat or Q&A context. For chat, try follow up questions, clarifications, ask to simplify or elaborate on answer, etc.
- Explore citations and sources
- Click on "settings" to try different options, tweak prompts, etc.
- Primary Repo - azure-search-openai-demo
- Revolutionize your Enterprise Data with ChatGPT: Next-gen Apps w/ Azure OpenAI and Cognitive Search
- Azure Cognitive Search
- Azure OpenAI Service
To remove your data from Azure Static Web Apps, go to https://identity.azurestaticapps.net/.auth/purge/aad
Currently only PDF docs are supported try to limit to smaller files. Support for large PDF file uploads and other doc version will be added soon
Enable application insights and check if you have all the required settings configured correctly
- AZURE_FORM_RECOGNIZER_SERVICE
- AZURE_OPENAI_CHATGPT_DEPLOYMENT
- AZURE_OPENAI_GPT_DEPLOYMENT
- AZURE_OPENAI_SERVICE
- AZURE_SEARCH_INDEX
- AZURE_SEARCH_KEY
- AZURE_SEARCH_SERVICE
- AZURE_STORAGE_ACCOUNT
- AZURE_STORAGE_CONTAINER
- AzureWebJobsStorage
- ENABLE_ORYX_BUILD
- FUNCTIONS_EXTENSION_VERSION
- FUNCTIONS_WORKER_RUNTIME
- SCM_DO_BUILD_DURING_DEPLOYMENT